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