{"name":"sort-object-keys","version":"2.0.1","keywords":["keys","object","sort"],"author":{"url":"http://keithcirkel.co.uk/","name":"Keith Cirkel","email":"npm@keithcirkel.co.uk"},"license":"MIT","_id":"sort-object-keys@2.0.1","maintainers":[{"name":"keithamus","email":"npm@keithcirkel.co.uk"}],"homepage":"https://github.com/keithamus/sort-object-keys#readme","bugs":{"url":"https://github.com/keithamus/sort-object-keys/issues"},"dist":{"shasum":"9eec95bb9276deb23649d5855b55bf489eca584b","tarball":"http://registry-npm.ywwl.com/sort-object-keys/download/sort-object-keys-2.0.1.tgz","fileCount":4,"integrity":"sha512-R89fO+z3x7hiKPXX5P0qim+ge6Y60AjtlW+QQpRozrrNcR1lw9Pkpm5MLB56HoNvdcLHL4wbpq16OcvGpEDJIg==","signatures":[{"sig":"MEUCICd7rVDYU/omZ0/ipBXMWPNEhsXfU13BPFD/6MHWZ5uYAiEA0tm44hjsHdFwuuOX88RocVCJ3f82TsU1A5v95l8gFAs=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":3132,"size":1476,"noattachment":false,"key":"/sort-object-keys/-/sort-object-keys-2.0.1.tgz"},"main":"index.js","type":"module","types":"index.d.ts","exports":{".":{"import":{"types":"./index.d.ts","default":"./index.js"}}},"gitHead":"cbbf3e1ea94c34bc5b272b1bf1c384eeba867910","scripts":{"sort":"sort-package-json","test":"node test.js","prepare":"husky"},"_npmUser":{"name":"keithamus","email":"npm@keithcirkel.co.uk"},"repository":{"url":"git+ssh://git@github.com/keithamus/sort-object-keys.git","type":"git"},"_npmVersion":"11.6.2","description":"Sort an object's keys, including an optional key list","directories":{},"_nodeVersion":"25.0.0","_hasShrinkwrap":false,"devDependencies":{"husky":"^9.1.7","sort-package-json":"^3.4.0"},"_npmOperationalInternal":{"tmp":"tmp/sort-object-keys_2.0.1_1761835616326_0.5263478020696077","host":"s3://npm-registry-packages-npm-production"},"readme":"# Sort Object\n\n[![Build Status](https://travis-ci.org/keithamus/sort-object-keys.svg)](https://travis-ci.org/keithamus/sort-object-keys)\n\nReturns a copy of an object with all keys sorted.\n\nThe second argument is optional and is used for ordering - to provide custom sorts. You can either pass an array containing ordered keys or a function to sort the keys (same signature as in [`Array.prototype.sort()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort)).\n\n```js\nimport assert from 'assert'\nimport sortObject from 'sort-object-keys'\n\nassert.equal(\n  JSON.stringify({\n    c: 1,\n    b: 1,\n    d: 1,\n    a: 1,\n  }),\n  JSON.stringify({\n    a: 1,\n    b: 1,\n    c: 1,\n    d: 1,\n  }),\n)\n\nassert.equal(\n  JSON.stringify(\n    sortObject(\n      {\n        c: 1,\n        b: 1,\n        d: 1,\n        a: 1,\n      },\n      ['b', 'a', 'd', 'c'],\n    ),\n  ),\n  JSON.stringify({\n    b: 1,\n    a: 1,\n    d: 1,\n    c: 1,\n  }),\n)\n\nfunction removeKeyAncCompareIndex(keyA, keyB) {\n  var a = parseInt(keyA.slice(4))\n  var b = parseInt(keyB.slice(4))\n  return a - b\n}\n\nassert.equal(\n  JSON.stringify(\n    sortObject(\n      {\n        'key-1': 1,\n        'key-3': 1,\n        'key-10': 1,\n        'key-2': 1,\n      },\n      removeKeyAncCompareIndex,\n    ),\n  ),\n  JSON.stringify({\n    'key-1': 1,\n    'key-2': 1,\n    'key-3': 1,\n    'key-10': 1,\n  }),\n)\n```\n","publish_time":1761835616519,"_cnpm_publish_time":1761835616519,"dist-tags":{"latest":"2.1.0"}}