LongestOrderedSequence
LongestOrderedSequence[list] finds the longest ordered sequence of contiguous or disjoint elements in list.
LongestOrderedSequence[list, p]finds the longest ordered sequence using the ordering functionp.
Examples
LongestOrderedSequence[{3, 1, 4, 1, 5, 9, 2, 6}]LongestOrderedSequence[{5, 3, 8, 1, 9}, Greater]Please visit the official Wolfram Language Reference for more details.