I\'m interested if there is a way, in LINQ, to check if all numbers in a list are increasing monotonically?
Example
List l
Here is a one-liner that will work:
var isIncreasing = list.OrderBy(x => x).SequenceEqual(list);
Or if you're going for performance, here is a one-liner that will only traverse the list once, and quits as soon as it reaches an element out of sequence:
var isIncreasing = !list.SkipWhile((x, i) => i == 0 || list[i - 1] <= x).Any();