Socket
Socket
Sign inDemoInstall

lodash.sortby

Package Overview
Dependencies
0
Maintainers
3
Versions
30
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    lodash.sortby

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


Version published
Weekly downloads
11M
increased by3.27%
Maintainers
3
Install size
75.0 kB
Created
Weekly downloads
 

Package description

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

Readme

Source

lodash.sortby v4.7.0

The lodash method _.sortBy exported as a Node.js module.

Installation

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.

Keywords

FAQs

Last updated on 13 Aug 2016

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc