Use _.restParam in _.sortByAll.

This commit is contained in:
Graeme Yeates
2015-04-11 22:52:32 -04:00
committed by jdalton
parent 5a1b526b6c
commit f82cbbab1c

View File

@@ -7325,25 +7325,16 @@
* _.map(_.sortByAll(users, ['user', 'age']), _.values);
* // => [['barney', 26], ['barney', 36], ['fred', 30], ['fred', 40]]
*/
function sortByAll() {
var args = arguments,
collection = args[0],
guard = args[3],
index = 0,
length = args.length - 1;
var sortByAll = restParam(function(collection, args) {
if (collection == null) {
return [];
}
var props = Array(length);
while (index < length) {
props[index] = args[++index];
var guard = args[2];
if (guard && isIterateeCall(args[0], args[1], guard)) {
args = args[0];
}
if (guard && isIterateeCall(args[1], args[2], guard)) {
props = args[1];
}
return baseSortByOrder(collection, baseFlatten(props), []);
}
return baseSortByOrder(collection, baseFlatten(args), []);
});
/**
* This method is like `_.sortByAll` except that it allows specifying the