TRUE if a vector is not sorted.
This function is generic (see Methods); method
functions can be written to handle specific classes of
data. Classes which already have methods for this function include:
integer,
character, and
logical.
notSorted(x, na.rm=T, increasing=T, strict=F)
TRUE then missing values are removed before computation.
Default
TRUE; if
FALSE then missing values cause an error.
increasing=F, check if
x is in decreasing order.
strict=T, return
FALSE if there are any duplicate values.
TRUE if
x is not sorted.
Character
data are tested according to the ASCII collating sequence, where digits
precede upper-case letters, which precede lower-case letters; the
position of other characters is unintuitive. Logical data are tested
according to the rule
FALSE < TRUE. Complex data are accepted,
but only the real parts are tested.
notSorted(c(1,2,3))
notSorted(c(4,1,2,3))
notSorted(letters)
if(notSorted(x)){
o <- order(x)
x <- x[o]
y <- y[o]
}