lib/model: Clean up generateClusterConfig, fix spurious test failure by sorting

This commit is contained in:
Jakob Borg
2016-11-17 07:45:45 +01:00
parent 2641062c17
commit 3088dac33b
3 changed files with 37 additions and 11 deletions

View File

@@ -203,3 +203,18 @@ func untypeoify(s string) string {
s = strings.Replace(s, "8", "B", -1)
return s
}
// DeviceIDs is a sortable slice of DeviceID
type DeviceIDs []DeviceID
func (l DeviceIDs) Len() int {
return len(l)
}
func (l DeviceIDs) Less(a, b int) bool {
return l[a].Compare(l[b]) == -1
}
func (l DeviceIDs) Swap(a, b int) {
l[a], l[b] = l[b], l[a]
}