1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-04 21:02:27 +08:00

refactor: update SortByField

This commit is contained in:
dudaodong
2023-09-04 11:03:22 +08:00
parent 8e484c4a6f
commit 4037b96cc4
3 changed files with 7 additions and 7 deletions

View File

@@ -1008,7 +1008,7 @@ func SortBy[T any](slice []T, less func(a, b T) bool) {
// default sortType is ascending (asc), if descending order, set sortType to desc
// This function is deprecated, use Sort and SortBy for replacement.
// Play: https://go.dev/play/p/fU1prOBP9p1
func SortByField(slice any, field string, sortType ...string) error {
func SortByField[T any](slice []T, field string, sortType ...string) error {
sv := sliceValue(slice)
t := sv.Type().Elem()