Learn R Programming

Kmisc (version 0.5.0)

str_sort: Sort a Vector of Strings

Description

Sorts a vector of strings lexically, as based on their UTF-8 ordering scheme. Lower-case letters are, by default, 'larger' than upper-case letters. This function will safely sort a UTF-8 vector.

Usage

str_sort(x, increasing = TRUE, ignore.case = FALSE, USE.NAMES = FALSE)

Arguments

x
a character vector (a vector of 'strings' to sort)
increasing
boolean. sort the string in increasing lexical order?
ignore.case
boolean. ignore case (so that, eg, a < A < b)
USE.NAMES
logical. if names attribute already exists on x, pass this through to the result?

Examples

Run this code
stopifnot( all( str_sort(c("cba", "fed")) == c("abc", "def") ) )

Run the code above in your browser using DataLab