Skip to content

Commit

Permalink
enhancement/sort-list
Browse files Browse the repository at this point in the history
Signed-off-by: yeya24 <yb532204897@gmail.com>
  • Loading branch information
yeya24 committed May 24, 2019
1 parent 7235f82 commit d9b1531
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cli/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"os"
"sort"
"strings"

"github.com/alibaba/pouch/apis/types"
Expand Down Expand Up @@ -354,6 +355,10 @@ func (n *NetworkListCommand) runNetworkList(args []string) error {
return err
}

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

display := n.cli.NewTableDisplay()
display.AddRow([]string{"NETWORK ID", "NAME", "DRIVER", "SCOPE"})
for _, network := range respNetworkResource {
Expand Down
8 changes: 8 additions & 0 deletions cli/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"os"
"sort"
"strings"

"github.com/alibaba/pouch/apis/filters"
Expand Down Expand Up @@ -336,6 +337,13 @@ func (v *VolumeListCommand) runVolumeList(args []string) error {
return fmt.Errorf("Conflicting options: --size (or --mountpoint) and -q")
}

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

display := v.cli.NewTableDisplay()
displayHead := []string{"VOLUME NAME"}

Expand Down

0 comments on commit d9b1531

Please sign in to comment.