mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-04 17:07:49 +00:00
Bump to v3.4.0.
This commit is contained in:
@@ -1,9 +1,6 @@
|
||||
import baseEach from '../internal/baseEach';
|
||||
import baseFlatten from '../internal/baseFlatten';
|
||||
import baseSortBy from '../internal/baseSortBy';
|
||||
import compareMultipleAscending from '../internal/compareMultipleAscending';
|
||||
import baseSortByOrder from '../internal/baseSortByOrder';
|
||||
import isIterateeCall from '../internal/isIterateeCall';
|
||||
import isLength from '../internal/isLength';
|
||||
|
||||
/**
|
||||
* This method is like `_.sortBy` except that it sorts by property names
|
||||
@@ -29,25 +26,16 @@ import isLength from '../internal/isLength';
|
||||
* // => [['barney', 26], ['barney', 36], ['fred', 30], ['fred', 40]]
|
||||
*/
|
||||
function sortByAll(collection) {
|
||||
var args = arguments;
|
||||
if (args.length > 3 && isIterateeCall(args[1], args[2], args[3])) {
|
||||
if (collection == null) {
|
||||
return [];
|
||||
}
|
||||
var args = arguments,
|
||||
guard = args[3];
|
||||
|
||||
if (guard && isIterateeCall(args[1], args[2], guard)) {
|
||||
args = [collection, args[1]];
|
||||
}
|
||||
var index = -1,
|
||||
length = collection ? collection.length : 0,
|
||||
props = baseFlatten(args, false, false, 1),
|
||||
result = isLength(length) ? Array(length) : [];
|
||||
|
||||
baseEach(collection, function(value) {
|
||||
var length = props.length,
|
||||
criteria = Array(length);
|
||||
|
||||
while (length--) {
|
||||
criteria[length] = value == null ? undefined : value[props[length]];
|
||||
}
|
||||
result[++index] = { 'criteria': criteria, 'index': index, 'value': value };
|
||||
});
|
||||
return baseSortBy(result, compareMultipleAscending);
|
||||
return baseSortByOrder(collection, baseFlatten(args, false, false, 1), []);
|
||||
}
|
||||
|
||||
export default sortByAll;
|
||||
|
||||
Reference in New Issue
Block a user