Skip to content

SortState

Sort state passed to custom sort handlers. Represents the current sorting configuration for a column.

// In a custom sort handler
const sortHandler: SortHandler = (rows, sortState, columns) => {
const { field, direction } = sortState;
console.log(`Sorting by ${field} ${direction === 1 ? 'ASC' : 'DESC'}`);
return [...rows].sort((a, b) => {
const aVal = a[field];
const bVal = b[field];
return (aVal < bVal ? -1 : aVal > bVal ? 1 : 0) * direction;
});
};
PropertyTypeDescription
fieldstringField to sort by
direction-1 | 1Sort direction: 1 = ascending, -1 = descending
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