github.com/georgethebeatle/containerd@v0.2.5/ctr/sort.go (about)

     1  package main
     2  
     3  import (
     4  	"sort"
     5  
     6  	"github.com/docker/containerd/api/grpc/types"
     7  )
     8  
     9  func sortContainers(c []*types.Container) {
    10  	sort.Sort(&containerSorter{c})
    11  }
    12  
    13  type containerSorter struct {
    14  	c []*types.Container
    15  }
    16  
    17  func (s *containerSorter) Len() int {
    18  	return len(s.c)
    19  }
    20  
    21  func (s *containerSorter) Swap(i, j int) {
    22  	s.c[i], s.c[j] = s.c[j], s.c[i]
    23  }
    24  
    25  func (s *containerSorter) Less(i, j int) bool {
    26  	return s.c[i].Id < s.c[j].Id
    27  }