🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

lodash.sortby

Package Overview
Dependencies
Maintainers
3
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lodash.sortby

The lodash method `_.sortBy` exported as a module.

4.7.0
latest
Source
npm
Version published
Weekly downloads
13M
-5.27%
Maintainers
3
Weekly downloads
 
Created

What is lodash.sortby?

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.

What are lodash.sortby's main functionalities?

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']);

Other packages similar to lodash.sortby

Keywords

lodash-modularized

FAQs

Package last updated on 13 Aug 2016

Did you know?

Socket

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.

Install

Related posts