Skip to content

Commit 7f56e3d

Browse files
authored
sortedAttributes sort by Key instead of value (#543)
1 parent 7abcb6f commit 7f56e3d

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

cmd/cli/cli.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -619,16 +619,15 @@ type attribute struct {
619619

620620
type attributeList []attribute
621621

622-
func (a attributeList) Len() int { return len(a) }
623-
func (a attributeList) Less(i, j int) bool { return a[i].key < a[j].key }
624-
func (a attributeList) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
625-
626622
func sortedAttributes(attrs toxiproxy.Attributes) attributeList {
627623
li := make(attributeList, 0, len(attrs))
628624
for k, v := range attrs {
629-
li = append(li, attribute{k, v.(float64)})
625+
li = append(li, attribute{k, v})
630626
}
631-
sort.Sort(li)
627+
sort.Slice(li, func(i, j int) bool {
628+
return li[i].key < li[j].key
629+
})
630+
632631
return li
633632
}
634633

0 commit comments

Comments
 (0)