diff --git a/internal/app/wwctl/node/list/main.go b/internal/app/wwctl/node/list/main.go index 26cd4e59..47a4a5d1 100644 --- a/internal/app/wwctl/node/list/main.go +++ b/internal/app/wwctl/node/list/main.go @@ -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") diff --git a/internal/app/wwctl/profile/list/main.go b/internal/app/wwctl/profile/list/main.go index fb3527f7..9702bc81 100644 --- a/internal/app/wwctl/profile/list/main.go +++ b/internal/app/wwctl/profile/list/main.go @@ -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") diff --git a/internal/pkg/node/constructors.go b/internal/pkg/node/constructors.go index 3a0666c4..ae9a7b7c 100644 --- a/internal/pkg/node/constructors.go +++ b/internal/pkg/node/constructors.go @@ -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 }