github.com/ezoic/ws@v1.0.4-0.20220713205711-5c1d69e074c5/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  }