sort tags by key (#4047)

Signed-off-by: changlin.shi <changlin.shi@ly.com>

Signed-off-by: changlin.shi <changlin.shi@ly.com>
This commit is contained in:
LHHDZ 2022-12-12 14:49:57 +08:00 committed by GitHub
parent 438146249f
commit bb289d7d69
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5,6 +5,7 @@ import (
"fmt" "fmt"
"github.com/seaweedfs/seaweedfs/weed/util" "github.com/seaweedfs/seaweedfs/weed/util"
"regexp" "regexp"
"sort"
"strings" "strings"
) )
@ -39,6 +40,11 @@ func FromTags(tags map[string]string) (t *Tagging) {
Value: v, Value: v,
}) })
} }
if tagArr := t.TagSet.Tag; len(tagArr) > 0 {
sort.SliceStable(tagArr, func(i, j int) bool {
return tagArr[i].Key < tagArr[j].Key
})
}
return return
} }