Skip to content

Commit

Permalink
use sortorder lib for sorting network list output
Browse files Browse the repository at this point in the history
Signed-off-by: Arash Deshmeh <[email protected]>
  • Loading branch information
adshmh committed Aug 8, 2018
1 parent 1d04f7d commit a921313
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion cli/command/network/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/docker/cli/opts"
"github.com/docker/docker/api/types"
"github.com/spf13/cobra"
"vbom.ml/util/sortorder"
)

type listOptions struct {
Expand Down Expand Up @@ -59,7 +60,7 @@ func runList(dockerCli command.Cli, options listOptions) error {
}

sort.Slice(networkResources, func(i, j int) bool {
return networkResources[i].Name < networkResources[j].Name
return sortorder.NaturalLess(networkResources[i].Name, networkResources[j].Name)
})

networksCtx := formatter.Context{
Expand Down
2 changes: 1 addition & 1 deletion cli/command/network/testdata/network-list-sort.golden
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
network-1-foo
network-10-foo
network-2-foo
network-10-foo

0 comments on commit a921313

Please sign in to comment.