mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-04 17:07:49 +00:00
Allow _.sortBy to accept an array for callback.
This commit is contained in:
@@ -74,8 +74,8 @@
|
||||
['Windows 7', 'internet explorer', '8'],
|
||||
['Windows XP', 'internet explorer', '7'],
|
||||
['Windows XP', 'internet explorer', '6'],
|
||||
['Windows 7', 'opera', '12'],
|
||||
['Windows 7', 'opera', '11'],
|
||||
//['Windows 7', 'opera', '12'],
|
||||
//['Windows 7', 'opera', '11'],
|
||||
['OS X 10.8', 'safari', '6'],
|
||||
['Windows 7', 'safari', '5'],
|
||||
['Windows XP', 'safari', '4']
|
||||
|
||||
12
test/test.js
12
test/test.js
@@ -6512,6 +6512,18 @@
|
||||
deepEqual(actual, [3, 1, 2]);
|
||||
});
|
||||
|
||||
test('should work with an array for `callback`', 1, function() {
|
||||
var objects = [
|
||||
{ 'a': 'x', 'b': 3 },
|
||||
{ 'a': 'y', 'b': 4 },
|
||||
{ 'a': 'x', 'b': 1 },
|
||||
{ 'a': 'y', 'b': 2 }
|
||||
];
|
||||
|
||||
var actual = _.sortBy(objects, ['a', 'b']);
|
||||
deepEqual(actual, [objects[2], objects[0], objects[3], objects[1]]);
|
||||
});
|
||||
|
||||
test('should work with a string for `callback`', 1, function() {
|
||||
var actual = _.pluck(_.sortBy(objects, 'num'), 'num');
|
||||
deepEqual(actual, [0, 11, 16, 74, 212, 991, 1515]);
|
||||
|
||||
Reference in New Issue
Block a user