Array.prototype.sort()

If compareFn is supplied, all non-undefined array
elements are sorted according to the return value
of the compare function (all undefined elements
are sorted to the end of the array, with no call
to compareFn).

compareFn(a, b)return valuesort order
> 0sort a after b, e.g.[b, a]
< 0sort a before b, e.g.[a, b]
=== 0keep original order of a and b