github.com/bhameyie/otto@v0.2.1-0.20160406174117-16052efa52ec/appfile/detect/sort.go (about)

     1  package detect
     2  
     3  // DetectorList is a sortable slice of Detectors, and implements
     4  // sort.Interface.
     5  type DetectorList []*Detector
     6  
     7  func (l DetectorList) Len() int {
     8  	return len(l)
     9  }
    10  
    11  func (l DetectorList) Less(i, j int) bool {
    12  	// Even though this fucntion is "less", we sort by highest priority first.
    13  	return l[i].Priority > l[j].Priority
    14  }
    15  
    16  func (l DetectorList) Swap(i, j int) {
    17  	l[i], l[j] = l[j], l[i]
    18  }