From 3359349acbbfb0aa8e208c5286ff7bd6537df2be Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Mon, 19 Feb 2024 17:02:47 +0300 Subject: [PATCH] Revert "[#972] Use slices.Sort* when useful" This reverts commit b871d7a5e83a616e4a769d08705ba7ba9394503f. Signed-off-by: Evgenii Stratonikov --- cmd/frostfs-cli/modules/control/shards_set_mode.go | 7 +++++-- pkg/services/tree/getsubtree_test.go | 6 ++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/cmd/frostfs-cli/modules/control/shards_set_mode.go b/cmd/frostfs-cli/modules/control/shards_set_mode.go index e73f1517..1c87b405 100644 --- a/cmd/frostfs-cli/modules/control/shards_set_mode.go +++ b/cmd/frostfs-cli/modules/control/shards_set_mode.go @@ -3,7 +3,7 @@ package control import ( "bytes" "fmt" - "slices" + "sort" "strings" rawclient "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/client" @@ -177,6 +177,9 @@ func getShardIDListFromIDFlag(cmd *cobra.Command, withAllFlag bool) [][]byte { res = append(res, raw) } - slices.SortFunc(res, bytes.Compare) + sort.Slice(res, func(i, j int) bool { + return bytes.Compare(res[i], res[j]) < 0 + }) + return res } diff --git a/pkg/services/tree/getsubtree_test.go b/pkg/services/tree/getsubtree_test.go index d220f1e2..63cdc73a 100644 --- a/pkg/services/tree/getsubtree_test.go +++ b/pkg/services/tree/getsubtree_test.go @@ -4,7 +4,7 @@ import ( "context" "errors" "path" - "slices" + "sort" "testing" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/pilorama" @@ -177,7 +177,9 @@ func TestGetSubTreeOrderAsc(t *testing.T) { require.True(t, found, "unknown node") } - require.True(t, slices.IsSorted(paths)) + require.True(t, sort.SliceIsSorted(paths, func(i, j int) bool { + return paths[i] < paths[j] + })) } var (