From f82cbbab1cde110b0e5643d8a58aa887aef7d95b Mon Sep 17 00:00:00 2001 From: Graeme Yeates Date: Sat, 11 Apr 2015 22:52:32 -0400 Subject: [PATCH] Use `_.restParam` in `_.sortByAll`. --- lodash.src.js | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/lodash.src.js b/lodash.src.js index ce67e0fbe..a8f1180e2 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -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