Move the sort to the constructors.
This commit is contained in:
@@ -30,17 +30,6 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
sort.Slice(nodes, func(i, j int) bool {
|
||||
if nodes[i].ClusterName.Get() < nodes[j].ClusterName.Get() {
|
||||
return true
|
||||
} else if nodes[i].ClusterName.Get() == nodes[j].ClusterName.Get() {
|
||||
if nodes[i].Id.Get() < nodes[j].Id.Get() {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
})
|
||||
|
||||
if ShowAll == true {
|
||||
for _, node := range nodes {
|
||||
fmt.Printf("################################################################################\n")
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||
"github.com/spf13/cobra"
|
||||
"os"
|
||||
"sort"
|
||||
)
|
||||
|
||||
func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
@@ -23,13 +22,6 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
sort.Slice(profiles, func(i, j int) bool {
|
||||
if profiles[i].Id.Get() < profiles[j].Id.Get() {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
})
|
||||
|
||||
for _, profile := range profiles {
|
||||
fmt.Printf("################################################################################\n")
|
||||
fmt.Printf("%-20s %-18s %s\n", "PROFILE NAME", "FIELD", "VALUE")
|
||||
|
||||
@@ -144,6 +144,17 @@ func (self *nodeYaml) FindAllNodes() ([]NodeInfo, error) {
|
||||
|
||||
}
|
||||
|
||||
sort.Slice(ret, func(i, j int) bool {
|
||||
if ret[i].ClusterName.Get() < ret[j].ClusterName.Get() {
|
||||
return true
|
||||
} else if ret[i].ClusterName.Get() == ret[j].ClusterName.Get() {
|
||||
if ret[i].Id.Get() < ret[j].Id.Get() {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
})
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user