From 80981a6aac0d1ad9d5ddadffdb7329927917a157 Mon Sep 17 00:00:00 2001 From: nilsocket Date: Wed, 14 Nov 2018 18:13:03 +0530 Subject: [PATCH] FromMap(), sorts and returns instead of calling New() (#433) Signed-off-by: nilsocket --- labels/labels.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/labels/labels.go b/labels/labels.go index d76ba0d08d..d1ba70b454 100644 --- a/labels/labels.go +++ b/labels/labels.go @@ -117,11 +117,13 @@ func New(ls ...Label) Labels { // FromMap returns new sorted Labels from the given map. func FromMap(m map[string]string) Labels { - l := make([]Label, 0, len(m)) + l := make(Labels, 0, len(m)) for k, v := range m { l = append(l, Label{Name: k, Value: v}) } - return New(l...) + sort.Sort(l) + + return l } // FromStrings creates new labels from pairs of strings.