Skip to content

SortByMultiple

cartographer


cartographer / sortByMultiple

sortByMultiple(items, sorts): CatalogItem[]

Defined in: queries/queryFunctions.ts:548

Sort items by multiple fields sequentially.

Applies sorts in reverse order so the first sort specification has highest priority.

CatalogItem[]

Array of items to sort

object[]

Array of sort specifications (field, descending, type)

CatalogItem[]

  • New sorted array (original array not mutated)
const sorted = sortByMultiple(items, [
{ field: 'year', descending: true, type: 'number' },
{ field: 'title', type: 'string' }
]);