underscore/slices.go
Ruidy fbf58eff42
Refresh documentation (#39)
* minor documentation fixes

* fix Hugo warnings

* add openssf badge
2024-12-03 09:29:53 +01:00

21 lines
401 B
Go

package underscore
import (
"sort"
"golang.org/x/exp/constraints"
)
// SortSliceASC sorts any slice ASCENDING
func SortSliceASC[T constraints.Ordered](s []T) {
sort.SliceStable(s, func(i, j int) bool {
return s[i] < s[j]
})
}
// SortSliceDESC sorts any slice DESCENDING
func SortSliceDESC[T constraints.Ordered](s []T) {
sort.SliceStable(s, func(i, j int) bool {
return s[i] > s[j]
})
}