mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-07 03:22:18 +00:00
424f38a9b6
Iteration order over go maps is random.
18 lines
262 B
Go
18 lines
262 B
Go
package common
|
|
|
|
import (
|
|
"golang.org/x/exp/constraints"
|
|
"golang.org/x/exp/slices"
|
|
)
|
|
|
|
func SortedKeys[K constraints.Ordered, V any](m map[K]V) []K {
|
|
keys := make([]K, len(m))
|
|
i := 0
|
|
for k := range m {
|
|
keys[i] = k
|
|
i++
|
|
}
|
|
slices.Sort(keys)
|
|
return keys
|
|
}
|