Files
lo/docs/data/it-issorted.md
T
2025-10-06 17:16:33 +02:00

583 B

name, slug, sourceRef, category, subCategory, signatures, variantHelpers, similarHelpers, position
name slug sourceRef category subCategory signatures variantHelpers similarHelpers position
IsSorted issorted it/seq.go#L720 it slice
func IsSorted[T constraints.Ordered](collection iter.Seq[T]) bool
core#slice#issorted
200

IsSorted checks if a sequence is sorted.

sorted := func(yield func(int) bool) {
    yield(1)
    yield(2)
    yield(3)
    yield(4)
}
unsorted := func(yield func(int) bool) {
    yield(1)
    yield(3)
    yield(2)
    yield(4)
}

fmt.Println(it.IsSorted(sorted))    // true
fmt.Println(it.IsSorted(unsorted))  // false