
Security News
MCP Community Begins Work on Official MCP Metaregistry
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
lodash.sortby
Advanced tools
The lodash.sortby package is a part of the Lodash library which provides utility functions for common programming tasks using a functional programming paradigm. This package offers a convenient way to sort collections like arrays and lists based on one or more iteratees.
Sorting an array of values
This feature allows you to sort an array of objects by a specific property. In the code sample, the 'users' array is sorted by the 'user' property.
const _ = require('lodash.sortby');
const users = [
{ 'user': 'fred', 'age': 48 },
{ 'user': 'barney', 'age': 36 },
{ 'user': 'fred', 'age': 40 },
{ 'user': 'barney', 'age': 34 }
];
const sortedUsers = _.sortBy(users, [function(o) { return o.user; }]);
Sorting by multiple criteria
This feature allows sorting by multiple criteria. In the code sample, the 'users' array is first sorted by the 'user' property and then by 'age'.
const _ = require('lodash.sortby');
const users = [
{ 'user': 'fred', 'age': 48 },
{ 'user': 'barney', 'age': 36 },
{ 'user': 'fred', 'age': 40 },
{ 'user': 'barney', 'age': 34 }
];
const sortedUsers = _.sortBy(users, ['user', 'age']);
array-sort is a small, fast array sort library that allows you to sort arrays of objects by one or more properties. It is similar to lodash.sortby but does not depend on the entire lodash library.
sort-array is another package that provides sorting capabilities for arrays. It can sort by multiple fields and offers a slightly different API compared to lodash.sortby.
The lodash method _.sortBy
exported as a Node.js module.
Using npm:
$ {sudo -H} npm i -g npm
$ npm i --save lodash.sortby
In Node.js:
var sortBy = require('lodash.sortby');
See the documentation or package source for more details.
FAQs
The lodash method `_.sortBy` exported as a module.
The npm package lodash.sortby receives a total of 11,366,462 weekly downloads. As such, lodash.sortby popularity was classified as popular.
We found that lodash.sortby demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.
Research
Security News
Malicious npm packages posing as developer tools target macOS Cursor IDE users, stealing credentials and modifying files to gain persistent backdoor access.