Interface: SortArrayOptions<Computed>
How sortArray sorts: by which properties, in which order.
Type Parameters
Computed
Computed
Properties
by?
optionalby?:string|string[]
The property to sort the items by, or several: the next one breaks the ties of the previous one. A name of computed sorts by that function's result. An item whose property is undefined (or missing) has the key undefined (see undefinedRank).
Default
none (the items themselves are compared)computed?
optionalcomputed?:object
Computed sort keys: a name used in by mapped to a function of the item returning its key. Used for an item whose property of that name is undefined.
Index Signature
[key: string]: (item) => string | number | bigint | boolean | symbol | null | undefined
customOrders?
optionalcustomOrders?:object
Named custom orders: a name, given in order, mapped to the list of the values in their order ({order: 'priority', customOrders: {priority: ['high', 'medium', 'low']}}). A value missing from the list goes before the values in it.
Index Signature
[key: string]: any
nullRank?
optionalnullRank?:1|-1
Where the null keys go, in both orders: 1 after the other values, -1 before them.
Default
1order?
optionalorder?:string|string[]
The order: 'asc', 'desc' or the name of a custom order of customOrders, or one per property of by. Any other value leaves the items unsorted.
Default
'asc'undefinedRank?
optionalundefinedRank?:1|-1
Where the undefined keys go, in both orders: 1 after the other values, -1 before them. An item which is itself undefined always goes last (Array.prototype.sort does not compare it).
Default
1