Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
image/tree: Remove longest->shortest sort
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
  • Loading branch information
vvoland committed Oct 31, 2025
commit 6fa59003391ed24343d463a3e4bb667144695c3e
11 changes: 1 addition & 10 deletions cli/command/image/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"fmt"
"os"
"slices"
"sort"
"strings"

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

// TODO: Replace with namesLongestToShortest := slices.SortedFunc(slices.Values(img.Names))
// once we move to Go 1.23.
namesLongestToShortest := make([]string, len(img.Names))
copy(namesLongestToShortest, img.Names)
sort.Slice(namesLongestToShortest, func(i, j int) bool {
return len(namesLongestToShortest[i]) > len(namesLongestToShortest[j])
})

for nameIdx, name := range namesLongestToShortest {
for nameIdx, name := range img.Names {
// Don't limit first names to the column width because only the last
// name will be printed alongside other columns.
if nameIdx < len(img.Names)-1 {
Expand Down
Loading