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 value | sort order |
|---|---|---|
| > 0 | sort a after b, e.g. | [b, a] |
| < 0 | sort a before b, e.g. | [a, b] |
| === 0 | keep original order of a and b |