Skip to content

Commit 6fa5900

Browse files
committed
image/tree: Remove longest->shortest sort
Signed-off-by: Paweł Gronowski <[email protected]>
1 parent 5836040 commit 6fa5900

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

cli/command/image/tree.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"fmt"
99
"os"
1010
"slices"
11-
"sort"
1211
"strings"
1312

1413
"github.com/containerd/platforms"
@@ -422,15 +421,7 @@ func printNames(out tui.Output, headers []imgColumn, img topImage, color, untagg
422421
_, _ = fmt.Fprint(out, headers[0].Print(untaggedColor, "<untagged>"))
423422
}
424423

425-
// TODO: Replace with namesLongestToShortest := slices.SortedFunc(slices.Values(img.Names))
426-
// once we move to Go 1.23.
427-
namesLongestToShortest := make([]string, len(img.Names))
428-
copy(namesLongestToShortest, img.Names)
429-
sort.Slice(namesLongestToShortest, func(i, j int) bool {
430-
return len(namesLongestToShortest[i]) > len(namesLongestToShortest[j])
431-
})
432-
433-
for nameIdx, name := range namesLongestToShortest {
424+
for nameIdx, name := range img.Names {
434425
// Don't limit first names to the column width because only the last
435426
// name will be printed alongside other columns.
436427
if nameIdx < len(img.Names)-1 {

0 commit comments

Comments
 (0)