From 9315d162174c38c9a93885cfc27b147067ba7c3f Mon Sep 17 00:00:00 2001 From: chris-pruitt Date: Thu, 24 Jan 2019 09:41:20 -0600 Subject: [PATCH] sort when getting versions of a single cluster --- main.go | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index d460911..ec959b6 100644 --- a/main.go +++ b/main.go @@ -25,7 +25,7 @@ func main() { flag.Parse() if *versionPtr { - fmt.Println("v1.2.0") + fmt.Println("v1.3.0") os.Exit(0) } @@ -76,8 +76,11 @@ func printDiff(x map[string]string, y map[string]string) { } func printMap(m map[string]string) { - for key, value := range m { - fmt.Println("\t"+key+":", value) + + keys := getSortedMapKeys(m) + + for _, key := range keys { + fmt.Println("\t"+key+":", m[key]) } } @@ -156,3 +159,13 @@ func removeDuplicates(stringSlice []string) []string { } return list } + +func getSortedMapKeys(m map[string]string) []string { + var keys []string + for k := range m { + keys = append(keys, k) + } + + sort.Strings(keys) + return keys +}