Sorting and Inverting a Map
This lesson covers important details on sorting and inverting a map.
We'll cover the following
Sorting a map
By default, a map is not sorted, not even on the value of its keys. If you want a sorted map, copy the keys (or values) to a slice, sort the slice (using the sort package), and print out the keys and/or values using the for-range on the slice. This is illustrated in the following program:
Get hands-on with 1400+ tech skills courses.