Skip to content

useCollator

@astryxdesign/core v0.7.1 · 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 '@astryx-vue/core/locale'
ts
const collator = useCollator({ numeric: true })

const sorted = computed(() => [...items.value].sort((a, b) => collator.value.compare(a, b)))

Best practices ​

GuidancePractices
DoReuse collator.value.compare in custom Table comparators and other user-visible string ordering.
Don'tConstruct Intl.Collator directly or call localeCompare; those bypass the provider-backed locale contract.