sortItems

DataTable
stable

Sort an array of internal data-table items by one or more sort keys and directions, with optional custom compare functions per key.

API

Signature

Full TypeScript signature sourced from the util file.

typescript

API

Parameters

Input parameters accepted by this util.

items
required
T[]
The array of internal items to sort. Each item must satisfy IInternalItem (has a raw property).
sortByItems
required
Array<IDataTableSortItem>
Ordered list of sort descriptors. Each entry specifies a key and an order ("asc" | "desc" | false).
options
{ transform?: (item: T) => Record<string, any> sortFunctions?: Record<string, TDataTableCompareFunction> sortRawFunctions?: Record<string, TDataTableCompareFunction> }
Optional overrides: transform maps an item before comparison; sortFunctions and sortRawFunctions provide per-key compare functions.

API

Return value

The value returned by this util.

A new sorted array of items. The original array is not mutated.

Usage

Examples

Ready-to-paste usage snippets.

Sort by a single key ascending

typescript