diff --git a/pkg/labels/labels.go b/pkg/labels/labels.go index da6f60bd13..3b462e68d7 100644 --- a/pkg/labels/labels.go +++ b/pkg/labels/labels.go @@ -18,7 +18,6 @@ import ( "encoding/json" "sort" "strconv" - "strings" "github.com/cespare/xxhash" ) @@ -285,11 +284,19 @@ func Compare(a, b Labels) int { } for i := 0; i < l; i++ { - if d := strings.Compare(a[i].Name, b[i].Name); d != 0 { - return d + if a[i].Name != b[i].Name { + if a[i].Name < b[i].Name { + return -1 + } else { + return 1 + } } - if d := strings.Compare(a[i].Value, b[i].Value); d != 0 { - return d + if a[i].Value != b[i].Value { + if a[i].Value < b[i].Value { + return -1 + } else { + return 1 + } } } // If all labels so far were in common, the set with fewer labels comes first.