Make SortedStringKeys call SortedKeys

I realized this could work if I make it generic.

Bug: 193460475
Test: m nothing
Change-Id: I2071b4cdbccb642ebdbb1342f7d91e581aab9f0f
This commit is contained in:
Cole Faust
2023-03-01 14:21:30 -08:00
parent 29ff4182f5
commit 195c7819fb
2 changed files with 2 additions and 53 deletions

View File

@@ -65,21 +65,8 @@ func JoinWithPrefixAndSeparator(strs []string, prefix string, sep string) string
// SortedStringKeys returns the keys of the given map in the ascending order.
//
// Deprecated: Use SortedKeys instead.
func SortedStringKeys(m interface{}) []string {
v := reflect.ValueOf(m)
if v.Kind() != reflect.Map {
panic(fmt.Sprintf("%#v is not a map", m))
}
if v.Len() == 0 {
return nil
}
iter := v.MapRange()
s := make([]string, 0, v.Len())
for iter.Next() {
s = append(s, iter.Key().String())
}
sort.Strings(s)
return s
func SortedStringKeys[V any](m map[string]V) []string {
return SortedKeys(m)
}
type Ordered interface {