# `Localize.Collation.Nif`
[🔗](https://github.com/elixir-localize/localize/blob/v0.39.0/lib/localize/collation/nif.ex#L1)

Collation NIF interface providing high-performance Unicode collation via ICU4C.

This module wraps the `nif_collation_cmp/10` function from `Localize.Nif` and
provides encoding of collation options to ICU enum values.

# `available?`

```elixir
@spec available?() :: boolean()
```

Returns whether the collation NIF backend is available.

### Returns

* `true` if the NIF shared library was loaded and the collation function is available.

* `false` otherwise.

# `nif_compare`

```elixir
@spec nif_compare(String.t(), String.t(), Localize.Collation.Options.t()) ::
  :lt | :eq | :gt
```

Compare two strings using the ICU NIF collator with full option support.

### Arguments

* `string_a` - the first string to compare.

* `string_b` - the second string to compare.

* `options` - a `%Localize.Collation.Options{}` struct.

### Returns

* `:lt` if `string_a` sorts before `string_b`.

* `:eq` if `string_a` and `string_b` are collation-equal.

* `:gt` if `string_a` sorts after `string_b`.

# `reorder_codes_supported?`

```elixir
@spec reorder_codes_supported?([atom()]) :: boolean()
```

Returns whether all reorder codes in the list can be mapped to ICU values.

### Arguments

* `reorder_codes` - a list of script code atoms.

### Returns

* `true` if all codes are recognized.

* `false` if any code is unrecognized.

### Examples

    iex> Localize.Collation.Nif.reorder_codes_supported?([:Grek, :Latn])
    true

    iex> Localize.Collation.Nif.reorder_codes_supported?([:Unknown])
    false

    iex> Localize.Collation.Nif.reorder_codes_supported?([])
    true

---

*Consult [api-reference.md](api-reference.md) for complete listing*
