refactor container sorting

This commit is contained in:
Bradley Cicenas
2017-01-12 19:24:12 +00:00
parent fd0cab6b7c
commit 6856a7028b
3 changed files with 28 additions and 55 deletions

View File

@@ -1,6 +1,8 @@
package main
import (
"sort"
"github.com/fsouza/go-dockerclient"
)
@@ -66,10 +68,10 @@ func (cm *ContainerMap) Get(id string) *Container {
// Return array of all containers, sorted by field
func (cm *ContainerMap) All() []*Container {
var containers []*Container
var containers Containers
for _, c := range cm.containers {
containers = append(containers, c)
}
SortContainers(GlobalConfig["sortField"], containers)
sort.Sort(containers)
return containers
}