mirror of
https://github.com/samber/lo.git
synced 2026-04-22 23:47:11 +08:00
941 B
941 B
name, slug, sourceRef, category, subCategory, playUrl, variantHelpers, similarHelpers, position, signatures
| name | slug | sourceRef | category | subCategory | playUrl | variantHelpers | similarHelpers | position | signatures | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| MaxBy | maxby | find.go#L459 | core | find | https://go.dev/play/p/JW1qu-ECwF7 |
|
|
220 |
|
Searches the maximum value of a collection using the given comparison function. Returns zero value when the collection is empty.
type Point struct{ X int }
max := lo.MaxBy([]Point{{1}, {5}, {3}}, func(a, b Point) bool {
return a.X > b.X
})
// {5}
Note: the comparison function is inconsistent with most languages, since we use the opposite of the usual convention.