From 2c4a349a743df16fe585e4386cc72cb9f5ec268b Mon Sep 17 00:00:00 2001 From: Tung Wu Date: Fri, 23 Aug 2024 20:12:10 +0800 Subject: [PATCH] Sort set keys by another method --- pkg/lib/saml/service_test.go | 2 +- pkg/util/setutil/set.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/lib/saml/service_test.go b/pkg/lib/saml/service_test.go index 32c35e74fb..d404eb8975 100644 --- a/pkg/lib/saml/service_test.go +++ b/pkg/lib/saml/service_test.go @@ -130,8 +130,8 @@ func TestSAMLService(t *testing.T) { Field: "NameIDPolicy/Format", Actual: format, Expected: []string{ - "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified", "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress", + "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified", }, Reason: "unsupported NameIDPolicy Format", }) diff --git a/pkg/util/setutil/set.go b/pkg/util/setutil/set.go index 438f0511d4..fa0d05f685 100644 --- a/pkg/util/setutil/set.go +++ b/pkg/util/setutil/set.go @@ -2,7 +2,7 @@ package setutil import ( "cmp" - "sort" + "slices" ) type Set[T cmp.Ordered] map[T]struct{} @@ -48,7 +48,7 @@ func (s Set[T]) Keys() []T { for k, _ := range s { keys = append(keys, k) } - sort.Slice(keys, cmp.Less) + slices.SortFunc(keys, cmp.Compare[T]) return keys }