Make _.sortBy moveundefined and NaN to the end of the array.

This commit is contained in:
John-David Dalton
2014-09-03 09:32:09 -07:00
parent d2aa55a3bd
commit cd4029dc61

View File

@@ -331,10 +331,13 @@
*/ */
function baseCompareAscending(value, other) { function baseCompareAscending(value, other) {
if (value !== other) { if (value !== other) {
if (value > other || typeof value == 'undefined') { var valIsReflexive = value === value,
othIsReflexive = other === other;
if (value > other || !valIsReflexive || (typeof value == 'undefined' && othIsReflexive)) {
return 1; return 1;
} }
if (value < other || typeof other == 'undefined') { if (value < other || !othIsReflexive || (typeof other == 'undefined' && valIsReflexive)) {
return -1; return -1;
} }
} }