{"_id":"sort-object-keys","_rev":"4266043","name":"sort-object-keys","description":"Sort an object's keys, including an optional key list","dist-tags":{"latest":"2.1.0"},"maintainers":[{"name":"keithamus","email":"npm@keithcirkel.co.uk"}],"time":{"modified":"2026-04-06T16:28:03.000Z","created":"2015-11-30T20:29:58.033Z","2.1.0":"2026-01-12T15:50:32.858Z","2.0.1":"2025-10-30T14:46:56.519Z","2.0.0":"2025-09-16T09:04:42.988Z","1.1.3":"2019-12-10T22:27:34.242Z","1.1.2":"2015-12-14T12:13:03.229Z","1.1.1":"2015-12-02T12:15:41.360Z","1.1.0":"2015-12-02T12:13:34.803Z","1.0.0":"2015-11-30T20:29:58.033Z"},"users":{},"author":{"name":"Keith Cirkel","email":"npm@keithcirkel.co.uk","url":"http://keithcirkel.co.uk/"},"repository":{"type":"git","url":"git+ssh://git@github.com/keithamus/sort-object-keys.git"},"versions":{"2.1.0":{"name":"sort-object-keys","version":"2.1.0","description":"Sort an object's keys, including an optional key list","keywords":["keys","object","sort"],"homepage":"https://github.com/keithamus/sort-object-keys#readme","bugs":{"url":"https://github.com/keithamus/sort-object-keys/issues"},"repository":{"type":"git","url":"git+ssh://git@github.com/keithamus/sort-object-keys.git"},"license":"MIT","author":{"name":"Keith Cirkel","email":"npm@keithcirkel.co.uk","url":"http://keithcirkel.co.uk/"},"type":"module","exports":{".":{"types":"./index.d.ts","default":"./index.js"}},"main":"index.js","types":"index.d.ts","scripts":{"format":"prettier -w .","prepare":"husky","sort":"sort-package-json","test":"node test.js"},"prettier":{"semi":false,"singleQuote":true},"devDependencies":{"husky":"^9.1.7","prettier":"^3.6.2","sort-package-json":"^3.4.0"},"gitHead":"2319c64ffbe7970c8987090ef63cb913668c587f","_id":"sort-object-keys@2.1.0","_nodeVersion":"25.2.1","_npmVersion":"11.6.2","dist":{"shasum":"af24fbb7b91fcca945399a04fa900a10f9506242","size":1540,"noattachment":false,"key":"/sort-object-keys/-/sort-object-keys-2.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/sort-object-keys/download/sort-object-keys-2.1.0.tgz"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:03258d76-e404-499d-96a2-58516c06f51f"}},"directories":{},"maintainers":[{"name":"keithamus","email":"npm@keithcirkel.co.uk"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/sort-object-keys_2.1.0_1768233032685_0.29368817380722834"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2026-01-12T15:50:32.858Z","publish_time":1768233032858,"_source_registry_name":"default","_cnpm_publish_time":1768233032858},"2.0.1":{"name":"sort-object-keys","version":"2.0.1","description":"Sort an object's keys, including an optional key list","keywords":["keys","object","sort"],"homepage":"https://github.com/keithamus/sort-object-keys#readme","bugs":{"url":"https://github.com/keithamus/sort-object-keys/issues"},"repository":{"type":"git","url":"git+ssh://git@github.com/keithamus/sort-object-keys.git"},"license":"MIT","author":{"name":"Keith Cirkel","email":"npm@keithcirkel.co.uk","url":"http://keithcirkel.co.uk/"},"type":"module","exports":{".":{"import":{"types":"./index.d.ts","default":"./index.js"}}},"main":"index.js","types":"index.d.ts","scripts":{"prepare":"husky","sort":"sort-package-json","test":"node test.js"},"devDependencies":{"husky":"^9.1.7","sort-package-json":"^3.4.0"},"gitHead":"cbbf3e1ea94c34bc5b272b1bf1c384eeba867910","_id":"sort-object-keys@2.0.1","_nodeVersion":"25.0.0","_npmVersion":"11.6.2","dist":{"shasum":"9eec95bb9276deb23649d5855b55bf489eca584b","size":1476,"noattachment":false,"key":"/sort-object-keys/-/sort-object-keys-2.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/sort-object-keys/download/sort-object-keys-2.0.1.tgz"},"_npmUser":{"name":"keithamus","email":"npm@keithcirkel.co.uk"},"directories":{},"maintainers":[{"name":"keithamus","email":"npm@keithcirkel.co.uk"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/sort-object-keys_2.0.1_1761835616326_0.5263478020696077"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2025-10-30T14:46:56.519Z","publish_time":1761835616519,"_source_registry_name":"default","_cnpm_publish_time":1761835616519},"2.0.0":{"name":"sort-object-keys","version":"2.0.0","description":"Sort an object's keys, including an optional key list","keywords":["keys","object","sort"],"homepage":"https://github.com/keithamus/sort-object-keys#readme","bugs":{"url":"https://github.com/keithamus/sort-object-keys/issues"},"repository":{"type":"git","url":"git+ssh://git@github.com/keithamus/sort-object-keys.git"},"license":"MIT","author":{"name":"Keith Cirkel","email":"npm@keithcirkel.co.uk","url":"http://keithcirkel.co.uk/"},"type":"module","exports":{".":{"import":{"types":"./index.d.ts","default":"./index.js"}}},"main":"index.js","types":"index.d.ts","scripts":{"sort":"sort-package-json","test":"node test.js"},"devDependencies":{"sort-package-json":"^3.4.0"},"_id":"sort-object-keys@2.0.0","gitHead":"1531dbde925c5c83408bdaaa8ecd0804276f4208","_nodeVersion":"24.8.0","_npmVersion":"11.6.0","dist":{"shasum":"e5dc3d75d07d4efe73ba6ac55f2f1a4380fdedf8","size":1470,"noattachment":false,"key":"/sort-object-keys/-/sort-object-keys-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/sort-object-keys/download/sort-object-keys-2.0.0.tgz"},"_npmUser":{"name":"keithamus","email":"npm@keithcirkel.co.uk"},"directories":{},"maintainers":[{"name":"keithamus","email":"npm@keithcirkel.co.uk"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/sort-object-keys_2.0.0_1758013482816_0.6381290195655962"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2025-09-16T09:04:42.988Z","publish_time":1758013482988,"_source_registry_name":"default","_cnpm_publish_time":1758013482988},"1.1.3":{"name":"sort-object-keys","version":"1.1.3","description":"Sort an object's keys, including an optional key list","keywords":["keys","object","sort"],"homepage":"https://github.com/keithamus/sort-object-keys#readme","bugs":{"url":"https://github.com/keithamus/sort-object-keys/issues"},"license":"MIT","author":{"name":"Keith Cirkel","email":"npm@keithcirkel.co.uk","url":"http://keithcirkel.co.uk/"},"main":"index.js","repository":{"type":"git","url":"git+ssh://git@github.com/keithamus/sort-object-keys.git"},"scripts":{"semantic-release":"travis-after-all && semantic-release pre && npm publish && semantic-release post","test":"node test.js"},"config":{"ghooks":{"pre-commit":"npm t","commit-msg":"validate-commit-msg"}},"devDependencies":{"ghooks":"^1.0.1","semantic-release":"^4.3.5","travis-after-all":"^1.4.4","validate-commit-msg":"^2.4.1"},"gitHead":"2a3d477a3cda1d575e5e80cb163c38c33ec1c3e2","_id":"sort-object-keys@1.1.3","_nodeVersion":"12.10.0","_npmVersion":"6.10.3","dist":{"shasum":"bff833fe85cab147b34742e45863453c1e190b45","size":1315,"noattachment":false,"key":"/sort-object-keys/-/sort-object-keys-1.1.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/sort-object-keys/download/sort-object-keys-1.1.3.tgz"},"maintainers":[{"name":"keithamus","email":"npm@keithcirkel.co.uk"}],"_npmUser":{"name":"keithamus","email":"npm@keithcirkel.co.uk"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/sort-object-keys_1.1.3_1576016854055_0.6884545511379667"},"_hasShrinkwrap":false,"publish_time":1576016854242,"_cnpm_publish_time":1576016854242,"_cnpmcore_publish_time":"2021-12-16T13:50:43.542Z"},"1.1.2":{"name":"sort-object-keys","version":"1.1.2","description":"Sort an object's keys, including an optional key list","keywords":["keys","object","sort"],"homepage":"https://github.com/keithamus/sort-object-keys#readme","bugs":{"url":"https://github.com/keithamus/sort-object-keys/issues"},"license":"MIT","author":{"name":"Keith Cirkel","email":"npm@keithcirkel.co.uk","url":"http://keithcirkel.co.uk/"},"files":["index.js"],"main":"index.js","repository":{"type":"git","url":"git+ssh://git@github.com/keithamus/sort-object-keys.git"},"scripts":{"semantic-release":"travis-after-all && semantic-release pre && npm publish && semantic-release post","test":"node test.js"},"devDependencies":{"semantic-release":"^4.3.5","travis-after-all":"^1.4.4"},"gitHead":"c095403bb657f28385b7c72264babc3d22c560d4","_id":"sort-object-keys@1.1.2","_shasum":"d3a6c48dc2ac97e6bc94367696e03f6d09d37952","_from":".","_npmVersion":"2.14.9","_nodeVersion":"0.12.9","_npmUser":{"name":"keithamus","email":"npm@keithcirkel.co.uk"},"dist":{"shasum":"d3a6c48dc2ac97e6bc94367696e03f6d09d37952","size":1223,"noattachment":false,"key":"/sort-object-keys/-/sort-object-keys-1.1.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/sort-object-keys/download/sort-object-keys-1.1.2.tgz"},"maintainers":[{"name":"keithamus","email":"npm@keithcirkel.co.uk"}],"directories":{},"publish_time":1450095183229,"_hasShrinkwrap":false,"_cnpm_publish_time":1450095183229,"_cnpmcore_publish_time":"2021-12-16T13:50:43.909Z"},"1.1.1":{"name":"sort-object-keys","version":"1.1.1","description":"Sort an object's keys, including an optional key list","main":"index.js","scripts":{"test":"node test.js"},"repository":{"type":"git","url":"git+ssh://git@github.com/keithamus/sort-object-keys.git"},"keywords":["object","sort","keys"],"author":{"name":"Keith Cirkel","email":"npm@keithcirkel.co.uk","url":"http://keithcirkel.co.uk/"},"license":"MIT","bugs":{"url":"https://github.com/keithamus/sort-object-keys/issues"},"homepage":"https://github.com/keithamus/sort-object-keys#readme","gitHead":"fdeda65401e9f902af655ce28e83b84ab0eace3c","_id":"sort-object-keys@1.1.1","_shasum":"cc8ad9b461cd33833d0c5272e6be0e31a971a242","_from":".","_npmVersion":"3.3.3","_nodeVersion":"0.12.7","_npmUser":{"name":"keithamus","email":"npm@keithcirkel.co.uk"},"dist":{"shasum":"cc8ad9b461cd33833d0c5272e6be0e31a971a242","size":1264,"noattachment":false,"key":"/sort-object-keys/-/sort-object-keys-1.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/sort-object-keys/download/sort-object-keys-1.1.1.tgz"},"maintainers":[{"name":"keithamus","email":"npm@keithcirkel.co.uk"}],"directories":{},"publish_time":1449058541360,"_hasShrinkwrap":false,"_cnpm_publish_time":1449058541360,"_cnpmcore_publish_time":"2021-12-16T13:50:44.118Z"},"1.1.0":{"name":"sort-object-keys","version":"1.1.0","description":"Sort an object's keys, including an optional key list","main":"index.js","scripts":{"test":"node test.js"},"repository":{"type":"git","url":"git+ssh://git@github.com/keithamus/sort-object-keys.git"},"keywords":["object","sort","keys"],"author":{"name":"Keith Cirkel","email":"npm@keithcirkel.co.uk","url":"http://keithcirkel.co.uk/"},"license":"MIT","bugs":{"url":"https://github.com/keithamus/sort-object-keys/issues"},"homepage":"https://github.com/keithamus/sort-object-keys#readme","gitHead":"1b3cc2769c74d003057152530a324e3c5fc6c6f2","_id":"sort-object-keys@1.1.0","_shasum":"cb2d709fd99048309bb8c79901f4dfbded375cab","_from":".","_npmVersion":"3.4.0","_nodeVersion":"4.2.2","_npmUser":{"name":"keithamus","email":"npm@keithcirkel.co.uk"},"dist":{"shasum":"cb2d709fd99048309bb8c79901f4dfbded375cab","size":1256,"noattachment":false,"key":"/sort-object-keys/-/sort-object-keys-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/sort-object-keys/download/sort-object-keys-1.1.0.tgz"},"maintainers":[{"name":"keithamus","email":"npm@keithcirkel.co.uk"}],"directories":{},"publish_time":1449058414803,"_hasShrinkwrap":false,"_cnpm_publish_time":1449058414803,"_cnpmcore_publish_time":"2021-12-16T13:50:44.331Z"},"1.0.0":{"name":"sort-object-keys","version":"1.0.0","description":"Sort an object's keys, including an optional key list","main":"index.js","scripts":{"test":"test.js"},"repository":{"type":"git","url":"git+ssh://git@github.com/keithamus/sort-object-keys.git"},"keywords":["object","sort","keys"],"author":{"name":"Keith Cirkel","email":"npm@keithcirkel.co.uk","url":"http://keithcirkel.co.uk/"},"license":"MIT","bugs":{"url":"https://github.com/keithamus/sort-object-keys/issues"},"homepage":"https://github.com/keithamus/sort-object-keys#readme","gitHead":"f87e818260e54d279fefa664e4f2d9224a4e1761","_id":"sort-object-keys@1.0.0","_shasum":"53a180c28f986900b698a729c5856a9d800de3a5","_from":".","_npmVersion":"3.4.0","_nodeVersion":"4.2.2","_npmUser":{"name":"keithamus","email":"npm@keithcirkel.co.uk"},"dist":{"shasum":"53a180c28f986900b698a729c5856a9d800de3a5","size":868,"noattachment":false,"key":"/sort-object-keys/-/sort-object-keys-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/sort-object-keys/download/sort-object-keys-1.0.0.tgz"},"maintainers":[{"name":"keithamus","email":"npm@keithcirkel.co.uk"}],"directories":{},"publish_time":1448915398033,"_hasShrinkwrap":false,"_cnpm_publish_time":1448915398033,"_cnpmcore_publish_time":"2021-12-16T13:50:44.579Z"}},"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","_attachments":{},"homepage":"https://github.com/keithamus/sort-object-keys#readme","bugs":{"url":"https://github.com/keithamus/sort-object-keys/issues"},"license":"MIT"}