Is a vector sorted?
is_sorted(x, asc = NA)isntSorted(x, asc = NA)
is_sorted
returns TRUE
or FALSE
isntSorted
returns 0
if sorted or the first position
that proves the vector is not sorted
An atomic vector.
Single logical. If NA
, the default, a vector is considered
sorted if it is either sorted ascending or sorted descending;
if FALSE
, a vector is sorted only if sorted descending;
if TRUE
, a vector is sorted only if sorted ascending.