Case-insensitive string comparator for use with Enum.sort/2.
Implements the compare/2 callback so this module can be passed directly
to Enum.sort/2 as a comparator:
Enum.sort(strings, Cldr.Collation.Insensitive)Uses the NIF backend when available for maximum performance, otherwise falls back to the pure Elixir implementation at secondary strength (which ignores case distinctions).
Summary
Functions
Compare two strings in a case-insensitive manner.
Functions
Compare two strings in a case-insensitive manner.
Arguments
string_a- the first string to compare.string_b- the second string to compare.
Returns
:ltifstring_asorts beforestring_b.:eqifstring_aandstring_bare collation-equal (ignoring case).:gtifstring_asorts afterstring_b.
Examples
iex> Cldr.Collation.Insensitive.compare("a", "A")
:eq
iex> Cldr.Collation.Insensitive.compare("b", "a")
:gt