|
|
|
@ -8,7 +8,13 @@ import "sort"
|
|
|
|
|
func SortRegions(regions []string) []string { |
|
|
|
|
sort.Slice(regions, func(i, j int) bool { |
|
|
|
|
r1, r2 := regions[i], regions[j] |
|
|
|
|
return regionLess(r1, r2) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
return regions |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func regionLess(r1, r2 string) bool { |
|
|
|
|
switch { |
|
|
|
|
case len(r1) < 4: |
|
|
|
|
switch { |
|
|
|
@ -24,6 +30,12 @@ func SortRegions(regions []string) []string {
|
|
|
|
|
default: |
|
|
|
|
return r1 < r2 |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (m *Cluster) sortRegions() { |
|
|
|
|
sort.Slice(m.Regions, func(i, j int) bool { |
|
|
|
|
r1 := m.Regions[i].Name |
|
|
|
|
r2 := m.Regions[j].Name |
|
|
|
|
return regionLess(r1, r2) |
|
|
|
|
}) |
|
|
|
|
return regions |
|
|
|
|
} |
|
|
|
|