From bb289d7d69f27e0ccef72d727053889eb6e37f9e Mon Sep 17 00:00:00 2001 From: LHHDZ Date: Mon, 12 Dec 2022 14:49:57 +0800 Subject: [PATCH] sort tags by key (#4047) Signed-off-by: changlin.shi Signed-off-by: changlin.shi --- weed/s3api/tags.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/weed/s3api/tags.go b/weed/s3api/tags.go index 0fc32241f..3df44fae0 100644 --- a/weed/s3api/tags.go +++ b/weed/s3api/tags.go @@ -5,6 +5,7 @@ import ( "fmt" "github.com/seaweedfs/seaweedfs/weed/util" "regexp" + "sort" "strings" ) @@ -39,6 +40,11 @@ func FromTags(tags map[string]string) (t *Tagging) { 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 }