collection/orderBy.js

  1. import _orderBy from 'lodash/orderBy'
  2. import { convert } from 'util/convert'
  3. /**
  4. * Replaces by an array of sorted by <code>iteratees</code> in specified <code>orders</code>.
  5. * @function
  6. * @memberof collection
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[{@link https://lodash.com/docs#identity|lodash.identity}]] The iteratees to sort by.
  10. * @param {string[]} [orders] The sort orders of <code>iteratees</code>.
  11. * @return {Object} Returns the updated object.
  12. * @see {@link https://lodash.com/docs#orderBy|lodash.orderBy} for more information.
  13. * @example
  14. * orderBy({ nested: { prop: [{ name: 'Yvo', age: 2 }, { name: 'Nico', age: 666 }, { name: 'Nico', age: 30 }] } }, 'nested.prop', ['name', 'age'], ['asc', 'desc'])
  15. * // => { nested: { prop: [{ name: 'Nico', age: 666 }, { name: 'Nico', age: 30 }, { name: 'Yvo', age: 2 }] } }
  16. * @since 0.3.0
  17. */
  18. const orderBy = convert(_orderBy)
  19. export { orderBy, orderBy as default }