diff --git a/cli/app.go b/cli/app.go index d4559e61..b021618c 100644 --- a/cli/app.go +++ b/cli/app.go @@ -59,7 +59,7 @@ var appListCommand = &cli.Command{ logrus.Fatal(err) } apps, err := config.GetApps(appFiles) - sort.Sort(config.ByServer(apps)) + sort.Sort(config.ByServerAndType(apps)) tableCol := []string{"Server", "Type", "Name"} table := createTable(tableCol) table.SetAutoMergeCellsByColumnIndex([]int{0}) diff --git a/config/env.go b/config/env.go index 015ea5ba..ca596b0e 100644 --- a/config/env.go +++ b/config/env.go @@ -40,6 +40,18 @@ func (a ByServer) Less(i, j int) bool { return strings.ToLower(a[i].File.Server) < strings.ToLower(a[j].File.Server) } +type ByServerAndType []App + +func (a ByServerAndType) Len() int { return len(a) } +func (a ByServerAndType) Swap(i, j int) { a[i], a[j] = a[j], a[i] } +func (a ByServerAndType) Less(i, j int) bool { + if a[i].File.Server == a[j].File.Server { + return strings.ToLower(a[i].Type) < strings.ToLower(a[j].Type) + } else { + return strings.ToLower(a[i].File.Server) < strings.ToLower(a[j].File.Server) + } +} + type ByType []App func (a ByType) Len() int { return len(a) }