Back to Lo

Core Minby

docs/data/core-minby.md

1.53.0268 B
Original Source

Searches the minimum value of a collection using the given comparison function. Returns the first minimal value; zero value when empty.

go
type Point struct{ X int }
min := lo.MinBy([]Point{{1}, {5}, {3}}, func(a, b Point) bool {
    return a.X < b.X
})
// {1}