feat(list): make listing alphabetical (#2077)

* feat: make listing alphabetical

* docs: added a comment about the rationale of the sorting
This commit is contained in:
LinuxJourney
2026-04-28 10:58:43 +02:00
committed by GitHub
parent 7e71bff458
commit d3ea46a9cd
+7
View File
@@ -3,6 +3,8 @@ package commands
import (
"context"
"fmt"
"slices"
"strings"
"github.com/89luca89/distrobox/pkg/config"
"github.com/89luca89/distrobox/pkg/containermanager"
@@ -37,5 +39,10 @@ func (c *ListCommand) Execute(ctx context.Context) (*ListResult, error) {
}
}
// Sort by container name to keep `distrobox list` output stable for downstream UIs; see https://github.com/89luca89/distrobox/issues/2071.
slices.SortFunc(distroboxes, func(a, b containermanager.Container) int {
return strings.Compare(a.Name, b.Name)
})
return &ListResult{Containers: distroboxes}, nil
}