Determine if a vector is sorted.

DESCRIPTION:

Returns 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.
Other numeric data is handled by the default method.

USAGE:

notSorted(x, na.rm=T, increasing=T, strict=F) 

REQUIRED ARGUMENTS:

x
a numerical, logical, or character S-PLUS object

OPTIONAL ARGUMENTS:

na.rm
logical flag: if TRUE then missing values are removed before computation. Default TRUE; if FALSE then missing values cause an error.
increasing
if increasing=F, check if x is in decreasing order.
strict
if strict=T, return FALSE if there are any duplicate values.

VALUE:

logical, TRUE if x is not sorted.

DETAILS:

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.

SEE ALSO:

EXAMPLES:

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] 
}