Function is_sorted

Source
pub fn is_sorted<T: Integer + SinglePrecision>(a: &[T], t: Trend) -> bool
Expand description

example: let nums = vec![1, 2, 3, 4, 5, ….]; is_sorted(&nums, Trend::Ascending); let nums = vec![9, 8, 7, 6, 5, ….]; is_sorted(&nums, Trend:Descending);

is_sorted check sequence is sorted or not but it doesn’t check the length of input. It’s better to avoid call the function when the length of input is 1 or 0;