github.com/searKing/golang/go@v1.2.117/container/hashring/sort.go (about)

     1  // Copyright 2020 The searKing Author. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package hashring
     6  
     7  import "sort"
     8  
     9  // Convenience types for common cases
    10  
    11  // IntSlice attaches the methods of Interface to []int, sorting in increasing order.
    12  type uint32Slice []uint32
    13  
    14  func (p uint32Slice) Len() int           { return len(p) }
    15  func (p uint32Slice) Less(i, j int) bool { return p[i] < p[j] }
    16  func (p uint32Slice) Swap(i, j int)      { p[i], p[j] = p[j], p[i] }
    17  
    18  // Sort is a convenience method.
    19  func (p uint32Slice) Sort() { sort.Sort(p) }