mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-06-07 05:42:42 +00:00
Method to sort keys in map.
This commit is contained in:
@@ -2,6 +2,7 @@ package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
)
|
||||
|
||||
// StringsIsSubset checks that subset is strict subset of full, and returns
|
||||
@@ -62,3 +63,15 @@ func StrSliceHasItem(s []string, item string) bool {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// StrMapSortedKeys returns keys of map[string]string sorted
|
||||
func StrMapSortedKeys(m map[string]string) []string {
|
||||
keys := make(sort.StringSlice, len(m))
|
||||
i := 0
|
||||
for k := range m {
|
||||
keys[i] = k
|
||||
i++
|
||||
}
|
||||
sort.Strings(keys)
|
||||
return keys
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user