Learn R Programming

Kmisc (version 0.5.0)

is.sorted: Test if an Object is Sorted

Description

Test if an object is sorted, without the cost of sorting it. Wrapper to is.unsorted.

Usage

is.sorted(x, na.rm = FALSE, strictly = FALSE)

Arguments

x
an R object with a class or a numeric, complex, character or logical vector.
na.rm
logical. Should missing values be removed before checking?
strictly
logical indicating if the check should be for strictly increasing values.

See Also

is.unsorted

Examples

Run this code
stopifnot( is.sorted(1, 2, 4) )

Run the code above in your browser using DataLab