naturalsort: Natural Ordering Sort

Description Usage Arguments Value Examples

View source: R/sort.R

Description

Natural ordering is a kind of alphanumerical ordering. naturalorder returns the order of the argument character #' vector in human natural ascending or descending order. naturalsort returns the sorted vector.

Usage

1
2
3
naturalorder(text, decreasing = FALSE, na.last = TRUE)

naturalsort(text, decreasing = FALSE, na.last = NA)

Arguments

text

a character vector to sort.

decreasing

logical.

na.last

logical. If NA, NAs will be removed of the result.

Value

For naturalorder, the results are indices of vector elements in natural order. For naturalsort, the results are sorted vectors.

Examples

1
2
3
text <- c("a-1.png", "a-2.png", "a-10.png")
print(sort(text))
print(naturalsort(text))

naturalsort documentation built on May 2, 2019, 5:55 a.m.