Support iteratee use cases for _.sortByAll and _.sortByOrder.

This commit is contained in:
Graeme Yeates
2015-04-12 13:01:52 -04:00
committed by jdalton
parent 9d90af409b
commit bc3771f3af
2 changed files with 39 additions and 25 deletions

View File

@@ -14185,10 +14185,10 @@
}
var objects = [
{ 'a': 'x', 'b': 3 },
{ 'a': 'y', 'b': 4 },
{ 'a': 'x', 'b': 1 },
{ 'a': 'y', 'b': 2 }
{ 'a': 'x', 'b': 3, c: 2 },
{ 'a': 'y', 'b': 4, c: 1 },
{ 'a': 'x', 'b': 1, c: 4},
{ 'a': 'y', 'b': 2, c: 3}
];
var stableOrder = [
@@ -14209,6 +14209,14 @@
deepEqual(actual, [objects[2], objects[0], objects[3], objects[1]]);
});
test('`_.' + methodName + '` should permit function comparators', 1, function() {
function b(obj) {
return obj.b * obj.c;
}
var actual = func(objects, [b, 'a']);
deepEqual(actual, [objects[2], objects[1], objects[0], objects[3]]);
});
test('`_.' + methodName + '` should perform a stable sort (test in IE > 8, Opera, and V8)', 1, function() {
var actual = func(stableOrder, ['a', 'c']);
deepEqual(actual, stableOrder);