aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBhargav Ravuri <[email protected]>2022-11-19 21:55:53 +0530
committerTomas Aschan <[email protected]>2025-08-29 22:35:41 +0200
commitccb49e5fea9f96c72827c71454198b28bf11ef49 (patch)
tree8f0e6c81280367c13ef0c16c797cfb1e89942bc3
parent7c651d1d398142c3056ff45df14f2019bad2146d (diff)
Print Default Values of String-to-String in Sorted Order
Signed-off-by: Bhargav Ravuri <[email protected]>
-rw-r--r--string_to_string.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/string_to_string.go b/string_to_string.go
index 890a01a..1d1e3bf 100644
--- a/string_to_string.go
+++ b/string_to_string.go
@@ -4,6 +4,7 @@ import (
"bytes"
"encoding/csv"
"fmt"
+ "sort"
"strings"
)
@@ -62,8 +63,15 @@ func (s *stringToStringValue) Type() string {
}
func (s *stringToStringValue) String() string {
+ keys := make([]string, 0, len(*s.value))
+ for k := range *s.value {
+ keys = append(keys, k)
+ }
+ sort.Strings(keys)
+
records := make([]string, 0, len(*s.value)>>1)
- for k, v := range *s.value {
+ for _, k := range keys {
+ v := (*s.value)[k]
records = append(records, k+"="+v)
}