sort-keys-with-context
Sort the keys of an object
Useful to get a deterministically ordered object, as the order of keys can vary between engines.
🍴 This is a fork of https://github.com/sindresorhus/sort-keys. The compartor function (if given) will be bound to the current object context. So it is possible to get the value of the keys:
{ let lvalue = thisleft; let rvalue = thisright; // compare based on keys and values // ...}
Install
$ npm install sort-keys-with-context
Usage
const sortKeys = ; ;//=> {a: 0, b: 0, c: 0} ;//=> {a: 0, b: {a: 0, b: 0}} ;//=> {a: 0, b: [{a: 0, b: 0}]} ;//=> {c: 0, b: 0, a: 0}
API
sortKeys(object, options?)
Returns a new object with sorted keys.
object
Type: object
options
Type: object
deep
Type: boolean
Default: false
Recursively sort keys, including keys of objects inside arrays.
compare
Type: Function