how to check if an `ArrayList<Long>` is in a...
# announcements
e
how to check if an
ArrayList<Long>
is in ascending order? Something available in stlib?
o
Not out of the box, AFAIR.
e
thanks anyway
i
Basically you need to compare each element with next to ensure it is not greater than the next one. You can pair elements that way with
zipWithNext
function, like:
Copy code
list.zipWithNext().all { (a, b) -> a <= b }
👍 2