\name{tieorder}
\alias{tieorder}
\title{ Ordering double breaking ties at random }
\description{
  This function works very similar to \code{\link[base]{order}} but in case of ties it breaks them by random.
}
\usage{
tieorder(x, decreasing = FALSE, index = seq(along = x), tiebreak = TRUE)
}
\arguments{
  \item{x}{ a vector of double or integer }
  \item{decreasing}{ TRUE to order decreasing (default FALSE = increasing) }
  \item{index}{ optionally a vector of integer index to be rearranged }
  \item{tiebreak}{ FALSE to avoid randomly breaking ties }
}
\details{
  NAs sorted last. Uses internally rsort_index.
}
\value{
  index rearranged
}
\author{ Jens Oehschlägel }
\seealso{ \code{\link[base]{order}}, \code{\link[distutil]{colOrder}}, \code{\link[distutil]{rowOrder}} }

\examples{
  tieorder(c(NA, NA, 2, 2, 1))
  tieorder(c(NA, NA, 2, 2, 1))
  tieorder(c(NA, NA, 2, 2, 1))
  tieorder(c(NA, NA, 2, 2, 1))
  x <- c(NA, NA, 2, 2, 1)
  n <- 100
  o <- integer(length(x))
  for (i in 1:n)
  o <- o + tieorder(x)
  o/n
}
\keyword{ utilities }
