Sorts works by publication date.
Array of works to sort
Sort order: 'asc' for ascending, 'desc' for descending (default: 'desc')
New array of works sorted by publication date
This function creates a new array and does not modify the original. Works without publication dates are sorted to the beginning (asc) or end (desc).
const newest = sortByDate(works, 'desc');const oldest = sortByDate(works, 'asc'); Copy
const newest = sortByDate(works, 'desc');const oldest = sortByDate(works, 'asc');
Sorts works by publication date.