Files
docker-cli/components/engine/pkg/graphdb/sort_linux.go
John Howard c3ca8eccc1 Windows: Factor out sqlite
Signed-off-by: John Howard <jhoward@microsoft.com>
Upstream-commit: 3f6127b173949cb36557601a56bc15ae2c45a698
Component: engine
2016-12-01 09:38:08 -08:00

28 lines
478 B
Go

package graphdb
import "sort"
type pathSorter struct {
paths []string
by func(i, j string) bool
}
func sortByDepth(paths []string) {
s := &pathSorter{paths, func(i, j string) bool {
return PathDepth(i) > PathDepth(j)
}}
sort.Sort(s)
}
func (s *pathSorter) Len() int {
return len(s.paths)
}
func (s *pathSorter) Swap(i, j int) {
s.paths[i], s.paths[j] = s.paths[j], s.paths[i]
}
func (s *pathSorter) Less(i, j int) bool {
return s.by(s.paths[i], s.paths[j])
}