mirror of
https://github.com/89luca89/distrobox.git
synced 2026-08-19 01:14:49 -05:00
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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user