The lodash method `_.sortBy` exported as a module.
npm install sortbyconstanzoA modularized lodash utility that exports the _.sortBy method as a standalone npm package.
``bash`
npm install sortbyconstanzo
`javascript
const sortBy = require('sortbyconstanzo');
// Sort array of objects by property
const users = [
{ name: 'Alice', age: 30 },
{ name: 'Bob', age: 25 },
{ name: 'Charlie', age: 35 }
];
sortBy(users, 'age');
// => [{ name: 'Bob', age: 25 }, { name: 'Alice', age: 30 }, { name: 'Charlie', age: 35 }]
// Sort by multiple properties
sortBy(users, ['age', 'name']);
// Sort with custom comparator
sortBy(users, user => user.age);
`
Sorts the elements of collection in ascending order by the results of running each element through iteratees.
Parameters:
- collection (Array|Object): The collection to iterate overiteratees` (string|Array|Function): The iteratees to sort by
-
Returns:
- (Array): The new sorted array
- Single-purpose module focused on sorting
- Stable sort algorithm for consistent results
- Supports multiple sort criteria
- Works with arrays and objects
- Lightweight and dependency-free
MIT
This package is part of the lodash modularized ecosystem. For more information about lodash, visit https://lodash.com/.