naturalorder {naturalsort}R Documentation

Natural Ordering Sort

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

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

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


[Package naturalsort version 0.1.3 Index]