Back to Lo

It Issortedby

docs/data/it-issortedby.md

1.53.0288 B
Original Source

IsSortedBy checks if a sequence is sorted by transform.

go
collection := func(yield func(string) bool) {
    yield("apple")
    yield("banana")
    yield("cherry")
}

sortedByLength := it.IsSortedBy(collection, func(s string) int {
    return len(s)
})
// true (5, 6, 6 is sorted)