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

sortobject

Package Overview
Dependencies
Maintainers
1
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sortobject

Returns a copy of an object, sorted deeply by its keys, without mangling any arrays inside of it

  • 5.6.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is sortobject?

The sortobject npm package is a utility for sorting the keys of an object. It can be used to ensure consistent key ordering, which can be useful for tasks such as comparing objects, generating consistent JSON output, and more.

What are sortobject's main functionalities?

Sort object keys alphabetically

This feature sorts the keys of an object in alphabetical order. The code sample demonstrates how to use the sortobject package to sort the keys of an object.

const sortobject = require('sortobject');
const obj = { b: 2, a: 1, c: 3 };
const sortedObj = sortobject(obj);
console.log(sortedObj); // { a: 1, b: 2, c: 3 }

Sort nested object keys

This feature sorts the keys of nested objects as well. The code sample shows how nested objects are sorted by their keys.

const sortobject = require('sortobject');
const obj = { b: { d: 4, c: 3 }, a: 1 };
const sortedObj = sortobject(obj);
console.log(sortedObj); // { a: 1, b: { c: 3, d: 4 } }

Other packages similar to sortobject

Keywords

FAQs

Package last updated on 29 Dec 2023

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