github.com/seeker-insurance/kit@v0.0.13/sortlib/numerics.go (about)

     1  package sortlib
     2  
     3  import (
     4  	"sort"
     5  
     6  	"github.com/seeker-insurance/kit/copyslice"
     7  	"github.com/seeker-insurance/kit/sortlib/sortable"
     8  )
     9  
    10  //Int creates a sorted copy of the slice of ints.
    11  func Int(a []int) []int {
    12  	b := copyslice.Int(a)
    13  	sort.Ints(b)
    14  	return b
    15  }
    16  
    17  //Uint creates a sorted copy of the slice of uints.
    18  func Uint(a []uint) []uint {
    19  	b := copyslice.Uint(a)
    20  	sort.Sort(sortable.Uints(b))
    21  	return b
    22  }
    23  
    24  //Float64 creates a sorted copy of the slice of float64s
    25  func Float64(a []float64) []float64 {
    26  	b := copyslice.Float64(a)
    27  	sort.Float64s(b)
    28  	return b
    29  }
    30  
    31  //Int64 creates a sorted copy of the slice of int64s
    32  func Int64(a []int64) []int64 {
    33  	b := copyslice.Int64(a)
    34  	sort.Sort(sortable.Int64s(b))
    35  	return b
    36  }
    37  
    38  //Uint64 creates a sorted copy of the slice of uint64s
    39  func Uint64(a []uint64) []uint64 {
    40  	b := copyslice.Uint64(a)
    41  	sort.Sort(sortable.Uint64s(b))
    42  	return b
    43  }
    44  
    45  //Bytes creates a sorted copy of the slice of bytes
    46  func Bytes(a []byte) []byte {
    47  	b := copyslice.Byte(a)
    48  	sort.Sort(sortable.Bytes(b))
    49  	return b
    50  }
    51  
    52  //Runes creates a sorted copy of the slice of runes
    53  func Runes(a []rune) []rune {
    54  	b := copyslice.Rune(a)
    55  	sort.Sort(sortable.Runes(b))
    56  	return b
    57  }