For use with sorting functions such as sortWith or
the built-in Array.prototype.sort(). Sorts in descending
numerical order, with valid numbers followed by NaN, then null,
then undefined.
Remarks
JavaScript's Array.prototype.sort() places undefined at the
end without even calling the comparator. This comparator, however,
still handles undefined so that it can be used with sort
implementations not based on Array.prototype.sort().
For use with sorting functions such as sortWith or the built-in
Array.prototype.sort()
. Sorts in descending numerical order, with valid numbers followed byNaN
, thennull
, thenundefined
.Remarks
JavaScript's
Array.prototype.sort()
placesundefined
at the end without even calling the comparator. This comparator, however, still handlesundefined
so that it can be used with sort implementations not based onArray.prototype.sort()
.Example