Sha256: dc88b0b6a85d5c9bfc1cd3b055ed73da1bb281f0ad2635f521dcf9f5b25289dc

Contents?: true

Size: 1.17 KB

Versions: 181

Compression:

Stored size: 1.17 KB

Contents

var arrayMap = require('./_arrayMap'),
    baseIteratee = require('./_baseIteratee'),
    baseMap = require('./_baseMap'),
    baseSortBy = require('./_baseSortBy'),
    baseUnary = require('./_baseUnary'),
    compareMultiple = require('./_compareMultiple'),
    identity = require('./identity');

/**
 * 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`.
 * @returns {Array} Returns the new sorted array.
 */
function baseOrderBy(collection, iteratees, orders) {
  var index = -1;
  iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(baseIteratee));

  var result = baseMap(collection, function(value, key, collection) {
    var criteria = arrayMap(iteratees, function(iteratee) {
      return iteratee(value);
    });
    return { 'criteria': criteria, 'index': ++index, 'value': value };
  });

  return baseSortBy(result, function(object, other) {
    return compareMultiple(object, other, orders);
  });
}

module.exports = baseOrderBy;

Version data entries

181 entries across 159 versions & 23 rubygems

Version Path
sumomo-0.10.8 data/sumomo/api_modules/node_modules/lodash/_baseOrderBy.js
sumomo-0.10.4 data/sumomo/api_modules/node_modules/lodash/_baseOrderBy.js
sumomo-0.10.3 data/sumomo/api_modules/node_modules/lodash/_baseOrderBy.js
sumomo-0.10.2 data/sumomo/api_modules/node_modules/lodash/_baseOrderBy.js
sumomo-0.10.1 data/sumomo/api_modules/node_modules/lodash/_baseOrderBy.js
sumomo-0.10.0 data/sumomo/api_modules/node_modules/lodash/_baseOrderBy.js
sumomo-0.9.0 data/sumomo/api_modules/node_modules/lodash/_baseOrderBy.js
sumomo-0.8.22 data/sumomo/api_modules/node_modules/lodash/_baseOrderBy.js
sumomo-0.8.21 data/sumomo/api_modules/node_modules/lodash/_baseOrderBy.js
sumomo-0.8.20 data/sumomo/api_modules/node_modules/lodash/_baseOrderBy.js
sumomo-0.8.17 data/sumomo/api_modules/node_modules/lodash/_baseOrderBy.js
sumomo-0.8.16 data/sumomo/api_modules/node_modules/lodash/_baseOrderBy.js
disco_app-0.18.0 test/dummy/node_modules/lodash/_baseOrderBy.js
disco_app-0.18.2 test/dummy/node_modules/lodash/_baseOrderBy.js
sumomo-0.8.15 data/sumomo/api_modules/node_modules/lodash/_baseOrderBy.js
disco_app-0.16.1 test/dummy/node_modules/lodash/_baseOrderBy.js
sumomo-0.8.14 data/sumomo/api_modules/node_modules/lodash/_baseOrderBy.js
sumomo-0.8.13 data/sumomo/api_modules/node_modules/lodash/_baseOrderBy.js
disco_app-0.15.2 test/dummy/node_modules/lodash/_baseOrderBy.js
disco_app-0.18.4 test/dummy/node_modules/lodash/_baseOrderBy.js