ts-ds / defaultCompare
Function: defaultCompare()
ts
function defaultCompare<T>(a, b): number;Defined in: sort/utils.ts:25
Default ascending order for numbers, strings and other values comparable with <.
- Strings are compared by UTF-16 code units:
'B' < 'a'. Use(a, b) => a.localeCompare(b)for alphabetical order. NaNhas no place in the numeric order, so it is treated as greater than any other value and ends up at the end of the array.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
a | T | First value to compare. |
b | T | Second value to compare. |
Returns
number
-1, 0 or 1.