useCollator
Returns the sanctioned locale-aware comparator for custom sorting. The collator is recreated when the provider locale or an option changes.
@astryxdesign/core/i18n
Signature
Call shape
useCollator(options?: Intl.CollatorOptions): Intl.CollatorParameters
| Name | Type and behavior |
|---|---|
options | Intl.CollatorOptions · optionalOptional collation behavior such as numeric ordering, sensitivity, punctuation handling, and case order. |
Returns
| Name | Type and behavior |
|---|---|
collator | Intl.CollatorA memoized collator bound to the active InternationalizationProvider locale. |
Usage
Returns the sanctioned locale-aware comparator for custom sorting. The collator is recreated when the provider locale or an option changes.
- Reuse collator.compare in custom Table comparators and other user-visible string ordering.
- Construct Intl.Collator directly or call localeCompare; those bypass the provider-backed locale contract.