github.com/psiphon-labs/goarista@v0.0.0-20160825065156-d002785f4c67/key/sort.go (about) 1 // Copyright (C) 2015 Arista Networks, Inc. 2 // Use of this source code is governed by the Apache License 2.0 3 // that can be found in the COPYING file. 4 5 package key 6 7 import ( 8 "sort" 9 ) 10 11 // SortedKeys returns the keys of the given map, in a sorted order. 12 func SortedKeys(m map[string]interface{}) []string { 13 res := make([]string, len(m)) 14 var i int 15 for k := range m { 16 res[i] = k 17 i++ 18 } 19 sort.Strings(res) 20 return res 21 }