SortedKeys returns the keys of a map in sorted order. K must satisfy cmp.Ordered (e.g. string, int). This is a pure function that does not modify the input map.
(m map[K]V)
| 61 | // K must satisfy cmp.Ordered (e.g. string, int). |
| 62 | // This is a pure function that does not modify the input map. |
| 63 | func SortedKeys[K cmp.Ordered, V any](m map[K]V) []K { |
| 64 | return slices.Sorted(maps.Keys(m)) |
| 65 | } |
| 66 | |
| 67 | // Any returns true if at least one element in the slice satisfies the predicate. |
| 68 | // Returns false for nil or empty slices. |
no outgoing calls