useCollator@astryxdesign/core v0.5.2 · useCollator

Usage

Returns the sanctioned locale-aware comparator for custom sorting. The collator is recreated when the provider locale or an option changes.

ts
import {useCollator} from '@astryxdesign/core/i18n'

Best practices

GuidancePractices
Do

Reuse collator.compare in custom Table comparators and other user-visible string ordering.

Don't

Construct Intl.Collator directly or call localeCompare; those bypass the provider-backed locale contract.

Parameters

ParamTypeDescription
options
Intl.CollatorOptions

Optional collation behavior such as numeric ordering, sensitivity, punctuation handling, and case order.

Returns

FieldTypeDescription
collatorIntl.Collator

A memoized collator bound to the active InternationalizationProvider locale.