mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-12 20:07:49 +00:00
_.sortBy should not error on nullish elements when sorting by multiple properties.
This commit is contained in:
@@ -5656,7 +5656,7 @@
|
|||||||
criteria = Array(length);
|
criteria = Array(length);
|
||||||
|
|
||||||
while (length--) {
|
while (length--) {
|
||||||
criteria[length] = value[iteratee[length]];
|
criteria[length] = value == null ? undefined : value[iteratee[length]];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
criteria = iteratee(value, key, collection);
|
criteria = iteratee(value, key, collection);
|
||||||
|
|||||||
@@ -9755,6 +9755,11 @@
|
|||||||
deepEqual(actual, [objects[2], objects[0], objects[3], objects[1]]);
|
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() {
|
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']);
|
var actual = _.sortBy(stableOrder, ['a', 'c']);
|
||||||
deepEqual(actual, stableOrder);
|
deepEqual(actual, stableOrder);
|
||||||
|
|||||||
Reference in New Issue
Block a user