Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lodash.orderby

Package Overview
Dependencies
Maintainers
3
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lodash.orderby

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

  • 4.6.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
453K
increased by1.48%
Maintainers
3
Weekly downloads
 
Created

What is lodash.orderby?

The lodash.orderby package is a utility library that provides a method for sorting collections (arrays or objects) based on multiple criteria. It is part of the larger Lodash library, which is known for its performance and ease of use.

What are lodash.orderby's main functionalities?

Sort by Single Property

This feature allows you to sort an array of objects by a single property. In this example, the users array is sorted by the 'user' property in ascending order.

const _ = require('lodash.orderby');
const users = [
  { 'user': 'fred',   'age': 48 },
  { 'user': 'barney', 'age': 34 },
  { 'user': 'fred',   'age': 40 },
  { 'user': 'barney', 'age': 36 }
];
const sortedUsers = _.orderBy(users, ['user'], ['asc']);
console.log(sortedUsers);

Sort by Multiple Properties

This feature allows you to sort an array of objects by multiple properties. In this example, the users array is first sorted by the 'user' property in ascending order, and then by the 'age' property in descending order.

const _ = require('lodash.orderby');
const users = [
  { 'user': 'fred',   'age': 48 },
  { 'user': 'barney', 'age': 34 },
  { 'user': 'fred',   'age': 40 },
  { 'user': 'barney', 'age': 36 }
];
const sortedUsers = _.orderBy(users, ['user', 'age'], ['asc', 'desc']);
console.log(sortedUsers);

Sort by Nested Properties

This feature allows you to sort an array of objects by nested properties. In this example, the users array is sorted by the 'details.age' property in ascending order.

const _ = require('lodash.orderby');
const users = [
  { 'user': 'fred',   'details': { 'age': 48 } },
  { 'user': 'barney', 'details': { 'age': 34 } },
  { 'user': 'fred',   'details': { 'age': 40 } },
  { 'user': 'barney', 'details': { 'age': 36 } }
];
const sortedUsers = _.orderBy(users, ['details.age'], ['asc']);
console.log(sortedUsers);

Other packages similar to lodash.orderby

Keywords

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc