Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

stri_sort_key

Sort Keys


Description

This function computes a locale-dependent sort key, which is an alternative character representation of the string that, when ordered in the C locale (which orders using the underlying bytes directly), will give an equivalent ordering to the original string. It is useful for enhancing algorithms that sort only in the C locale (e.g., the strcmp function in libc) with the ability to be locale-aware.

Usage

stri_sort_key(str, ..., opts_collator = NULL)

Arguments

str

a character vector

...

additional settings for opts_collator

opts_collator

a named list with ICU Collator's options, see stri_opts_collator, NULL for default collation options

Details

For more information on ICU's Collator and how to tune it up in stringi, refer to stri_opts_collator.

See also stri_rank for ranking strings with a single character vector, i.e., generating relative sort keys.

Value

The result is a character vector with the same length as str that contains the sort keys. The output is marked as bytes-encoded.

References

Collation - ICU User Guide, http://userguide.icu-project.org/collation

See Also

Examples

stri_sort_key(c('hladny', 'chladny'), locale='pl_PL')
stri_sort_key(c('hladny', 'chladny'), locale='sk_SK')

stringi

Character String Processing Facilities

v1.6.1
file LICENSE
Authors
Marek Gagolewski [aut, cre, cph] (<https://orcid.org/0000-0003-0637-6028>), Bartek Tartanus [ctb], and others (stringi source code); IBM, Unicode, Inc. and others (ICU4C source code, Unicode Character Database)
Initial release
2021-05-05

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.