
The function sorts a character vector according to the locale-dependent lexicographic order.
stri_sort(str, decreasing = FALSE, na_last = NA, ..., opts_collator = NULL)
a character vector
a single logical value; should the sort order
be nondecreasing (FALSE
, default, i.e., weakly increasing)
or nonincreasing (TRUE
)?
a single logical value; controls the treatment of NA
s
in str
. If TRUE
, then missing values in str
are put
at the end; if FALSE
, they are put at the beginning;
if NA
, then they are removed from the output
additional settings for opts_collator
a named list with ICU Collator's options,
see stri_opts_collator
, NULL
for default collation options
The result is a sorted version of str
,
i.e., a character vector.
For more information on ICU's Collator and how to tune it up
in stringi, refer to stri_opts_collator
.
As usual in stringi, non-character inputs are coerced to strings, see an example below for a perhaps non-intitive behavior of lexicographic sorting on numeric inputs.
This function uses a stable sort algorithm (STL's stable_sort
),
which performs up to str
.
Collation - ICU User Guide, http://userguide.icu-project.org/collation
Other locale_sensitive:
%s<%()
,
stri_compare()
,
stri_count_boundaries()
,
stri_duplicated()
,
stri_enc_detect2()
,
stri_extract_all_boundaries()
,
stri_locate_all_boundaries()
,
stri_opts_collator()
,
stri_order()
,
stri_split_boundaries()
,
stri_trans_tolower()
,
stri_unique()
,
stri_wrap()
,
stringi-locale
,
stringi-search-boundaries
,
stringi-search-coll
# NOT RUN {
stri_sort(c("hladny", "chladny"), locale="pl_PL")
stri_sort(c("hladny", "chladny"), locale="sk_SK")
stri_sort(sample(LETTERS))
stri_sort(c(1, 100, 2, 101, 11, 10))
stri_sort(c(1, 100, 2, 101, 11, 10), numeric=TRUE)
# }
Run the code above in your browser using DataLab