Created
August 1, 2017 08:05
-
-
Save l-vitaly/a1efa97bb6fef50291ec27df7d1f58fe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func sortMap(m map[string]string) []string { | |
list := make(sort.StringSlice, len(m)) | |
i := 0 | |
for name := range m { | |
list[i] = name | |
i++ | |
} | |
list.Sort() | |
result := make([]string, len(list)) | |
for i, name := range list { | |
result[i] = m[name] | |
} | |
return result | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment