You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

13 lines
202 B

1 year ago
  1. package genutils
  2. import "sort"
  3. type Lesser[T any] interface {
  4. Less(T) bool
  5. }
  6. func SortSlice[T Lesser[T]](slice []T) {
  7. sort.Slice(slice, func(i, j int) bool {
  8. return slice[i].Less(slice[j])
  9. })
  10. }