Skip to content

Instantly share code, notes, and snippets.

@l-vitaly
Created August 1, 2017 08:05
Show Gist options
  • Save l-vitaly/a1efa97bb6fef50291ec27df7d1f58fe to your computer and use it in GitHub Desktop.
Save l-vitaly/a1efa97bb6fef50291ec27df7d1f58fe to your computer and use it in GitHub Desktop.
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