_baseSortBy.js 543 B

12345678910111213141516171819202122
  1. /**
  2. * The base implementation of `_.sortBy` which uses `comparer` to define the
  3. * sort order of `array` and replaces criteria objects with their corresponding
  4. * values.
  5. *
  6. * @private
  7. * @param {Array} array The array to sort.
  8. * @param {Function} comparer The function to define sort order.
  9. * @returns {Array} Returns `array`.
  10. */
  11. function baseSortBy(array, comparer) {
  12. var length = array.length;
  13. array.sort(comparer);
  14. while (length--) {
  15. array[length] = array[length].value;
  16. }
  17. return array;
  18. }
  19. module.exports = baseSortBy;