Creates a copy of the specified array of items sorted by the optional compareFunc. This is done because the native sort function mutates the array.
items
compareFunc
Type of item in the specified items array.
Array to sort.
Optional
Optional compare function to use for sorting.
Array of items sorted naturally or by the specified compareFunc.
Use the toSorted built-in method on arrays.
Creates a copy of the specified array of
items
sorted by the optionalcompareFunc
. This is done because the native sort function mutates the array.