Closed piotr-dobrogost closed 5 years ago
See my comment in #60 .
@alalonde
I can not image that anyone would be negatively surprised that sorting ['c', null, null, 'a', undefined, 'b']
he would now get sorted sequence ["a", "b", "c", null, null, undefined]
instead of random mess ["a", "b", null, null, "c", undefined]
they have been getting earlier.
All who wanted to handle undefined
values must have already used custom comparator and for all others the behavior would be clearly better.
Could you please reconsider merging this fix?
Array.prototype.sort()
has the following guarantee:For example:
However, default comparison function used by the library –
defaultCompare
– does not make this guarantee:which is unfortunate as it makes default sorting broken in case of any
undefined
values. The fix should be easy: change currentto
which gives: