Sorts an array of objects by one or more properties with configurable sort order.
The type of objects in the array
The array to sort
Array of property names to sort by (in priority order)
Optional
Optional sort order for each property ('asc' or 'desc'). Defaults to 'asc'.
The sorted array
Sort by count descending, then tag ascending
const sortedObjs = sortObjArray(tags, ['count', 'tag'], ['desc', 'asc']); Copy
const sortedObjs = sortObjArray(tags, ['count', 'tag'], ['desc', 'asc']);
Sort by count descending (default order for other props is asc)
const sortedObjs = sortObjArray(tags, ['count', 'tag'], ['desc']); Copy
const sortedObjs = sortObjArray(tags, ['count', 'tag'], ['desc']);
Sorts an array of objects by one or more properties with configurable sort order.