mirror of
https://github.com/rjNemo/underscore
synced 2026-06-06 02:26:42 +00:00
Replace usage of golang.org/x/exp/constraints with Go 1.22 cmp/slices. Update .golangci.yml to new v2 format and enable gofmt/goimports. Refactor imports and type constraints across codebase for consistency.
20 lines
359 B
Go
20 lines
359 B
Go
package underscore
|
|
|
|
import (
|
|
"cmp"
|
|
"sort"
|
|
)
|
|
|
|
// SortSliceASC sorts any slice ASCENDING
|
|
func SortSliceASC[T cmp.Ordered](s []T) {
|
|
sort.SliceStable(s, func(i, j int) bool {
|
|
return s[i] < s[j]
|
|
})
|
|
}
|
|
|
|
// SortSliceDESC sorts any slice DESCENDING
|
|
func SortSliceDESC[T cmp.Ordered](s []T) {
|
|
sort.SliceStable(s, func(i, j int) bool {
|
|
return s[i] > s[j]
|
|
})
|
|
}
|