naturalorder {naturalsort} | R Documentation |
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.
naturalorder(text, decreasing = FALSE, na.last = TRUE) naturalsort(text, decreasing = FALSE, na.last = NA)
text |
a character vector to sort. |
decreasing |
logical. |
na.last |
logical. If |
For naturalorder
, the results are indices of vector elements in natural order.
For naturalsort
, the results are sorted vectors.
text <- c("a-1.png", "a-2.png", "a-10.png") print(sort(text)) print(naturalsort(text))