builtInSort
The default sortHandler used when none is provided in GridConfig.sortHandler.
Reads each column’s sortComparator (falling back to defaultComparator)
and returns a sorted copy of the rows array.
Use this as a fallback inside a custom sortHandler when you only need to
intercept sorting for specific columns or add pre/post-processing:
function builtInSort(rows: T[], sortState: SortState, columns: ColumnConfig<T>[]): T[]Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
rows | T[] | |
sortState | SortState | |
columns | ColumnConfig<T>[] |
Example
Section titled “Example”import { builtInSort } from '@toolbox-web/grid';import type { SortHandler } from '@toolbox-web/grid';
const customSort: SortHandler<Employee> = (rows, state, columns) => { // Server-side sort for the "salary" column, client-side for everything else if (state.field === 'salary') { return fetch(`/api/employees?sort=${state.field}&dir=${state.direction}`) .then(res => res.json()); } return builtInSort(rows, state, columns);};
grid.gridConfig = { sortHandler: customSort };See Also
Section titled “See Also”GridConfig.sortHandlerfor configuring the handlerdefaultComparatorfor the comparator used per column
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