You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I propose a function to allow a loop over a map in stable order. It takes all keys of the map, sorts them, and loops over the slides, each loop, yields a key-pair.
// SortedByKey returns an iterator for the given map that// yields the key-value pairs in sorted order.funcSortedByKey[Map~map[K]V, K cmp.Ordered, Vany](mMap) iter.Seq2[K, V] {
returnfunc(yieldfunc(K, V) bool) {
for_, k:=rangeslices.Sorted(Keys(m)) {
if!yield(k, m[k]) {
return
}
}
}
}
datdao, luantranminh, hmhuan, ledongthuc, luathn and 19 moreicholy, fzipp, phucledien, hieunguyen-sens-vn, duythinht and 11 more