sortbyconstanzo
v4.7.4
Published
The lodash method `_.sortBy` exported as a module.
Downloads
4
Readme
sortbyconstanzo
A modularized lodash utility that exports the _.sortBy method as a standalone npm package.
Installation
npm install sortbyconstanzoUsage
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);API
sortBy(collection, iteratees)
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
Features
- 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
License
MIT
Related
This package is part of the lodash modularized ecosystem. For more information about lodash, visit https://lodash.com/.
