Sorts a collection in place.
:warning: The default comparator for
Array is defined by the
The left and right values are coerced to strings and compared lexicographically.
For all other collections that implement
Object.compare is the
The comparator must be a function that accepts two values and returns a number.
A comparator for numbers should subtract the right from the left and expresses both the direction and magnitude of the difference. If the magnitude of the difference is not meaningful, a comparator should return only Infinity, -Infinity, or 0, to increase the usefulness of the comparator.
Returns a sorted array of the values in this collection.