refactored all commands under cli/command/ to use sort.Slice instead of declaring custom types for sorting
Signed-off-by: Arash Deshmeh <adeshmeh@ca.ibm.com>
This commit is contained in:
@ -8,18 +8,9 @@ import (
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/cli/cli/command/formatter"
|
||||
"github.com/docker/cli/opts"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
type byVolumeName []*types.Volume
|
||||
|
||||
func (r byVolumeName) Len() int { return len(r) }
|
||||
func (r byVolumeName) Swap(i, j int) { r[i], r[j] = r[j], r[i] }
|
||||
func (r byVolumeName) Less(i, j int) bool {
|
||||
return r[i].Name < r[j].Name
|
||||
}
|
||||
|
||||
type listOptions struct {
|
||||
quiet bool
|
||||
format string
|
||||
@ -63,7 +54,9 @@ func runList(dockerCli command.Cli, options listOptions) error {
|
||||
}
|
||||
}
|
||||
|
||||
sort.Sort(byVolumeName(volumes.Volumes))
|
||||
sort.Slice(volumes.Volumes, func(i, j int) bool {
|
||||
return volumes.Volumes[i].Name < volumes.Volumes[j].Name
|
||||
})
|
||||
|
||||
volumeCtx := formatter.Context{
|
||||
Output: dockerCli.Out(),
|
||||
|
||||
Reference in New Issue
Block a user