defaultComparator
Default comparator used when no column-level sortComparator is configured.
Pushes null/undefined to the end and compares remaining values via > / <
operators, which works correctly for numbers and falls back to lexicographic
comparison for strings.
Use this as a fallback inside a custom sortComparator when you only need
special handling for certain values:
function defaultComparator(a: unknown, b: unknown): numberParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
a | unknown | |
b | unknown |
Example
Section titled “Example”import { defaultComparator } from '@toolbox-web/grid';
const column = { field: 'priority', sortComparator: (a, b, rowA, rowB) => { // Pin "urgent" to the top, then fall back to default ordering if (a === 'urgent') return -1; if (b === 'urgent') return 1; return defaultComparator(a, b); },};See Also
Section titled “See Also”BaseColumnConfig.sortComparatorfor column-level comparatorsbuiltInSortfor the full sort handler that uses this comparator
AI assistants: For complete API documentation, implementation guides, and code examples for this library, see https://raw.githubusercontent.com/OysteinAmundsen/toolbox/main/llms-full.txt