diff --git a/go/inventory/v1/types.go b/go/inventory/v1/types.go index 4f79eee6..fb026a26 100644 --- a/go/inventory/v1/types.go +++ b/go/inventory/v1/types.go @@ -14,10 +14,23 @@ type GPUs []GPU type Nodes []Node type ClusterStorage []Storage +var _ sort.Interface = (*Nodes)(nil) var _ sort.Interface = (*GPUs)(nil) var _ sort.Interface = (*CPUInfoS)(nil) var _ sort.Interface = (*ClusterStorage)(nil) +func (s Nodes) Len() int { + return len(s) +} + +func (s Nodes) Swap(i, j int) { + s[i], s[j] = s[j], s[i] +} + +func (s Nodes) Less(i, j int) bool { + return s[i].Name < s[j].Name +} + func (s CPUInfoS) Len() int { return len(s) }