github.com/simonmittag/ws@v1.1.0-rc.5.0.20210419231947-82b846128245/autobahn/main_go17.go (about)

     1  // +build !go1.8
     2  
     3  package main
     4  
     5  import "sort"
     6  
     7  func sortBySegment(s []string) {
     8  	sort.Sort(segmentSorter(s))
     9  }
    10  
    11  type segmentSorter []string
    12  
    13  func (s segmentSorter) Less(i, j int) bool {
    14  	return compareBySegment(s[i], s[j]) < 0
    15  }
    16  
    17  func (s segmentSorter) Len() int {
    18  	return len(s)
    19  }
    20  
    21  func (s segmentSorter) Swap(i, j int) {
    22  	s[i], s[j] = s[j], s[i]
    23  }