sort.go 423 B

12345678910111213141516171819202122
  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. package key
  5. import (
  6. "sort"
  7. )
  8. // SortedKeys returns the keys of the given map, in a sorted order.
  9. func SortedKeys(m map[string]interface{}) []string {
  10. res := make([]string, len(m))
  11. var i int
  12. for k := range m {
  13. res[i] = k
  14. i++
  15. }
  16. sort.Strings(res)
  17. return res
  18. }