Sorts an array after copying it, returning the copy.
This sort is stable, as it calls Array.prototype.sort under the hood which
is guaranteed to be stable from ECMAScript 2019 onwards.
If you are using a comparator that computes a key for each item that is
expensive, consider using sortedOn which will compute all the keys up
front before sorting.
Note that this differs from Array.prototype.toSorted in that it will sort
numbers correctly by default.
Sorts an array after copying it, returning the copy.
This sort is stable, as it calls
Array.prototype.sortunder the hood which is guaranteed to be stable from ECMAScript 2019 onwards.If you are using a comparator that computes a key for each item that is expensive, consider using sortedOn which will compute all the keys up front before sorting.
Note that this differs from
Array.prototype.toSortedin that it will sort numbers correctly by default.