MCPcopy
hub / github.com/lodash/lodash / baseOrderBy

Function baseOrderBy

lodash.js:3768–3795  ·  view source on GitHub ↗

* The base implementation of `_.orderBy` without param guards. * * @private * @param {Array|Object} collection The collection to iterate over. * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by. * @param {string[]} orders The sort orders of `iteratees

(collection, iteratees, orders)

Source from the content-addressed store, hash-verified

3766 * @returns {Array} Returns the new sorted array.
3767 */
3768 function baseOrderBy(collection, iteratees, orders) {
3769 if (iteratees.length) {
3770 iteratees = arrayMap(iteratees, function(iteratee) {
3771 if (isArray(iteratee)) {
3772 return function(value) {
3773 return baseGet(value, iteratee.length === 1 ? iteratee[0] : iteratee);
3774 };
3775 }
3776 return iteratee;
3777 });
3778 } else {
3779 iteratees = [identity];
3780 }
3781
3782 var index = -1;
3783 iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
3784
3785 var result = baseMap(collection, function(value, key, collection) {
3786 var criteria = arrayMap(iteratees, function(iteratee) {
3787 return iteratee(value);
3788 });
3789 return { 'criteria': criteria, 'index': ++index, 'value': value };
3790 });
3791
3792 return baseSortBy(result, function(object, other) {
3793 return compareMultiple(object, other, orders);
3794 });
3795 }
3796
3797 /**
3798 * The base implementation of `_.pick` without support for individual

Callers 2

orderByFunction · 0.85
lodash.jsFile · 0.85

Calls 8

arrayMapFunction · 0.85
baseGetFunction · 0.85
baseUnaryFunction · 0.85
getIterateeFunction · 0.85
baseMapFunction · 0.85
baseSortByFunction · 0.85
compareMultipleFunction · 0.85
iterateeFunction · 0.70

Tested by

no test coverage detected