sort2: Sorting or ordering of vectors

View source: R/utils.R

sort2R Documentation

Sorting or ordering of vectors

Description

Sort (or order) a vector or factor (partially) into ascending or descending order keeping NA values in place.

Usage

sort2(
  x,
  decreasing = FALSE,
  index.return = FALSE,
  method = c("auto", "shell", "radix")
)

Arguments

x

a numeric, complex, or logical vector

decreasing

logical; if TRUE, x is sorted in decreasing order

index.return

logical; if TRUE, an integer vector with the ordering index is returned

method

the sorting method used, "shell" (default) or "radix"; see order

Examples

set.seed(1)
x <- sample(10)
x[4:6] <- NA

## compare
sort2(x)
sort(x, na.last = NA)
sort(x, na.last = TRUE)
sort(x, na.last = FALSE)


raredd/rawr documentation built on March 4, 2024, 1:36 a.m.