github.com/go/docker@v1.12.0-rc2/cmd/docker/usage.go (about) 1 package main 2 3 import ( 4 "sort" 5 6 "github.com/docker/docker/cli" 7 ) 8 9 type byName []cli.Command 10 11 func (a byName) Len() int { return len(a) } 12 func (a byName) Swap(i, j int) { a[i], a[j] = a[j], a[i] } 13 func (a byName) Less(i, j int) bool { return a[i].Name < a[j].Name } 14 15 // TODO(tiborvass): do not show 'daemon' on client-only binaries 16 17 func sortCommands(commands []cli.Command) []cli.Command { 18 dockerCommands := make([]cli.Command, len(commands)) 19 copy(dockerCommands, commands) 20 sort.Sort(byName(dockerCommands)) 21 return dockerCommands 22 }