_.sortBy should not error on nullish elements when sorting by multiple properties.

This commit is contained in:
John-David Dalton
2014-08-20 01:24:33 -07:00
parent df3540b0f9
commit 1423dcb619
2 changed files with 6 additions and 1 deletions

View File

@@ -5656,7 +5656,7 @@
criteria = Array(length);
while (length--) {
criteria[length] = value[iteratee[length]];
criteria[length] = value == null ? undefined : value[iteratee[length]];
}
} else {
criteria = iteratee(value, key, collection);

View File

@@ -9755,6 +9755,11 @@
deepEqual(actual, [objects[2], objects[0], objects[3], objects[1]]);
});
test('should not error on nullish elements when sorting by multiple properties', 1, function() {
var actual = _.sortBy(objects.concat(undefined), ['a', 'b']);
deepEqual(actual, [objects[2], objects[0], objects[3], objects[1], undefined]);
});
test('should perform a stable sort when sorting by multiple properties (test in IE > 8, Opera, and V8)', 1, function() {
var actual = _.sortBy(stableOrder, ['a', 'c']);
deepEqual(actual, stableOrder);