refactored cli/compose and cli/command/trust to use sort.Slice and removed custom types used for sorting

Signed-off-by: Arash Deshmeh <adeshmeh@ca.ibm.com>
This commit is contained in:
Arash Deshmeh
2018-07-08 15:08:17 -04:00
parent 2b221d8f1c
commit 71d650ee17
8 changed files with 33 additions and 93 deletions

View File

@ -985,16 +985,12 @@ services:
}
func serviceSort(services []types.ServiceConfig) []types.ServiceConfig {
sort.Sort(servicesByName(services))
sort.Slice(services, func(i, j int) bool {
return services[i].Name < services[j].Name
})
return services
}
type servicesByName []types.ServiceConfig
func (sbn servicesByName) Len() int { return len(sbn) }
func (sbn servicesByName) Swap(i, j int) { sbn[i], sbn[j] = sbn[j], sbn[i] }
func (sbn servicesByName) Less(i, j int) bool { return sbn[i].Name < sbn[j].Name }
func TestLoadAttachableNetwork(t *testing.T) {
config, err := loadYAML(`
version: "3.2"