sortCompare
The sortCompare() function compares two strings using a locale-aware Intl.Collator.
It uses the locale "en-US-u-kn-true" with { usage: "sort", sensitivity: "variant", numeric: false, ignorePunctuation: false }, which means the comparison is case- and accent-sensitive, punctuation affects ordering, and digits are compared as strings (not numerically).
Interactive example
Syntax
Classic signature
typescript
function sortCompare(
valueB: string,
valueA: string
): numberCurried signature
typescript
function sortCompare(
valueB: string
): (valueA: string) => numberParameters
valueB: Reference value used for the comparison.valueA: Value to compare againstvalueB.
Return value
A number less than 0 if valueA is ordered before valueB, greater than 0 if after, and 0 if they are equivalent according to the collator rules.
