Rev 12256 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
\name{order}\title{Ordering Permutation}\alias{order}\alias{sort.list}\description{\code{order} returns a permutation which rearranges its firstargument into ascending order, breaking ties by further arguments.\code{sort.list} is the same, using only one argument but allowingpartial sorting.}\usage{order(\dots, na.last = TRUE)sort.list(x, partial, na.last = TRUE)}\arguments{\item{\dots}{a sequence of vectors, all of the same length.}\item{x}{a vector.}\item{partial}{vector of indices for partial sorting.}\item{na.last}{for controlling the treatment of \code{NA}s.If \code{TRUE}, missing values in the data are put last; if\code{FALSE}, they are put first; if \code{NA}, they are removed.Currently, \code{TRUE} is the only possible value.}}\details{In the case of ties in the first vector, values in the second are usedto break the ties. If the values are still tied, values in the laterarguments are used to break the tie (see the first example).\code{\link{NA}} values are treated as greater than any other valuesso that permutations returned by \code{order} move \code{NA} values tothe top end of the array. Other options are not (yet) implemented in\R.\code{partial} is supplied for compatibility with otherimplementations of S, but the sorting is always complete.}\seealso{\code{\link{sort}} and \code{\link{rank}}.}\examples{(ii <- order(x <- c(1,1,3:1,1:4,3), y <- c(9,9:1), z <-c(2,1:9)))## 6 5 2 1 7 4 10 8 3 9rbind(x,y,z)[,ii] # shows the reordering (ties via 2nd & 3rd arg)## rearrange matched vectors so that the first is in ascending orderx <- c(5:1, 6:8, 12:9)y <- (x - 5)^2o <- order(x)rbind(x[o], y[o])}\keyword{univar}\keyword{manip}