go-libs/helper/sortMapKeys.go
2025-03-18 20:13:24 +01:00

13 lines
293 B
Go

package helper
import "sort"
// Helper function to get sorted keys from a map
func SortMapKeys(data map[string]interface{}) []string {
keys := make([]string, 0, len(data))
for key := range data {
keys = append(keys, key)
}
sort.Strings(keys) // Sort keys alphabetically
return keys
}