sort-keys
Advanced tools
Sort the keys of an object
Weekly downloads
Changelog
https://github.com/sindresorhus/sort-keys/compare/v4.2.0...v5.0.0
Readme
Sort the keys of an object
Useful to get a deterministically ordered object, as the order of keys can vary between engines.
$ npm install sort-keys
import sortKeys from 'sort-keys';
sortKeys({c: 0, a: 0, b: 0});
//=> {a: 0, b: 0, c: 0}
sortKeys({b: {b: 0, a: 0}, a: 0}, {deep: true});
//=> {a: 0, b: {a: 0, b: 0}}
sortKeys({b: [{b: 0, a: 0}], a: 0}, {deep: true});
//=> {a: 0, b: [{a: 0, b: 0}]}
sortKeys({c: 0, a: 0, b: 0}, {
compare: (a, b) => -a.localeCompare(b)
});
//=> {c: 0, b: 0, a: 0}
sortKeys([{b: 0, a:2}], {deep: true});
//=> [{a: 2, b: 0}]
Returns a new object with sorted keys.
Type: object | Array
Type: object
Type: boolean
Default: false
Recursively sort keys, including keys of objects inside arrays.
Type: Function
Sort the keys of an object
The npm package sort-keys receives a total of 12,852,165 weekly downloads. As such, sort-keys popularity was classified as popular.
We found that sort-keys demonstrated a not healthy version release cadence and project activity. It has 1 open source maintainer collaborating on the project.