Skip to content

Commit df28fff

Browse files
committed
[coconut] Sort printed maps by key
1 parent 287b16b commit df28fff

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

coconut/control/control.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import (
3434
"io"
3535
"os"
3636
"regexp"
37+
"sort"
3738
"strconv"
3839
"strings"
3940
"time"
@@ -221,7 +222,7 @@ func stringMapToString(stringMap map[string]string, indent string) string {
221222
if len(stringMap) == 0 {
222223
return ""
223224
}
224-
accumulator := make([]string, len(stringMap))
225+
accumulator := make(sort.StringSlice, len(stringMap))
225226
i := 0
226227
for k, v := range stringMap {
227228
value := v
@@ -231,6 +232,7 @@ func stringMapToString(stringMap map[string]string, indent string) string {
231232
accumulator[i] = indent + k + ": " + value
232233
i++
233234
}
235+
accumulator.Sort()
234236
return strings.Join(accumulator, "\n")
235237
}
236238

0 commit comments

Comments
 (0)