KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
In Go, what's the easiest way to get the keys in a map sorted alphabetically? This is the shortest way I can do it: package main import "container/vector" import "fmt" import "sort" func main() { m := map[string]string {"b":"15", "z":"123123", "x":"sdf", "a":"12"} var keys vector.StringVector; for k,_ := range ( m ) { keys.Push(k) } sort.Sort( &keys ) fmt.Printf("%v\n", keys) }
Tags (comma-separated)
Save Edits
Cancel