{"_id":"sort-keys","_rev":"3959874","name":"sort-keys","description":"Sort the keys of an object","dist-tags":{"latest":"6.0.0"},"maintainers":[{"name":"sindresorhus","email":""}],"time":{"modified":"2025-09-01T01:44:43.000Z","created":"2014-06-28T13:20:39.025Z","6.0.0":"2025-08-24T16:43:49.687Z","5.1.0":"2024-09-06T15:20:17.582Z","5.0.0":"2021-04-16T19:18:56.621Z","4.2.0":"2020-12-30T07:11:45.350Z","4.1.0":"2020-10-13T21:13:40.643Z","4.0.0":"2019-08-15T10:25:04.466Z","3.0.0":"2019-05-06T08:18:04.347Z","2.0.0":"2017-06-09T22:08:28.583Z","1.1.2":"2016-05-18T04:44:33.631Z","1.1.1":"2015-07-23T13:49:59.229Z","1.1.0":"2015-07-11T13:08:57.311Z","1.0.0":"2014-08-13T13:26:26.900Z","0.1.0":"2014-06-28T13:20:39.025Z"},"users":{"leesei":true,"456wyc":true,"rocket0191":true,"danielbayley":true,"quafoo":true,"td3":true},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"repository":{"type":"git","url":"git+https://github.com/sindresorhus/sort-keys.git"},"versions":{"6.0.0":{"name":"sort-keys","version":"6.0.0","description":"Sort the keys of an object","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/sort-keys.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":{"types":"./index.d.ts","default":"./index.js"},"sideEffects":false,"engines":{"node":">=20"},"scripts":{"test":"xo && ava && tsd"},"keywords":["sort","object","keys","key","stable","deterministic","deep","recursive","recursively","array","sorted","sorting"],"dependencies":{"is-plain-obj":"^4.1.0"},"devDependencies":{"ava":"^6.4.1","tsd":"^0.33.0","xo":"^1.2.2"},"_id":"sort-keys@6.0.0","gitHead":"89df51ec111cd1ba5b7820b30445a8eb7e1d66f7","types":"./index.d.ts","bugs":{"url":"https://github.com/sindresorhus/sort-keys/issues"},"homepage":"https://github.com/sindresorhus/sort-keys#readme","_nodeVersion":"20.19.1","_npmVersion":"10.9.2","dist":{"shasum":"46fccab1341c38ddd406f262d43a5237e9a58296","size":5189,"noattachment":false,"key":"/sort-keys/-/sort-keys-6.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/sort-keys/download/sort-keys-6.0.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/sort-keys_6.0.0_1756053829498_0.10246067205951581"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2025-08-24T16:43:49.687Z","publish_time":1756053829687,"_source_registry_name":"default","_cnpm_publish_time":1756053829687},"5.1.0":{"name":"sort-keys","version":"5.1.0","description":"Sort the keys of an object","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/sort-keys.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":"./index.js","types":"./index.d.ts","sideEffects":false,"engines":{"node":">=12"},"scripts":{"test":"xo && ava && tsd"},"keywords":["sort","object","keys","key","stable","deterministic","deep","recursive","recursively","array","sorted","sorting"],"dependencies":{"is-plain-obj":"^4.0.0"},"devDependencies":{"ava":"^6.1.3","tsd":"^0.31.2","xo":"^0.59.3"},"_id":"sort-keys@5.1.0","gitHead":"74b6172ef0f25060cc05dead79f4ffb1cd979556","bugs":{"url":"https://github.com/sindresorhus/sort-keys/issues"},"homepage":"https://github.com/sindresorhus/sort-keys#readme","_nodeVersion":"18.20.2","_npmVersion":"10.6.0","dist":{"shasum":"50a3f3d1ad3c5a76d043e0aeeba7299241e9aa5c","size":2351,"noattachment":false,"key":"/sort-keys/-/sort-keys-5.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/sort-keys/download/sort-keys-5.1.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/sort-keys_5.1.0_1725636017460_0.834174920846354"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2024-09-06T15:20:17.582Z","publish_time":1725636017582,"_source_registry_name":"default","_cnpm_publish_time":1725636017582},"5.0.0":{"name":"sort-keys","version":"5.0.0","description":"Sort the keys of an object","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/sort-keys.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":"./index.js","engines":{"node":">=12"},"scripts":{"test":"xo && ava && tsd"},"keywords":["sort","object","keys","key","stable","deterministic","deep","recursive","recursively","array","sorted","sorting"],"dependencies":{"is-plain-obj":"^4.0.0"},"devDependencies":{"ava":"^3.15.0","tsd":"^0.14.0","xo":"^0.38.2"},"gitHead":"0efa286f2923d83a825a3efd30e5c52f1f9a9307","bugs":{"url":"https://github.com/sindresorhus/sort-keys/issues"},"homepage":"https://github.com/sindresorhus/sort-keys#readme","_id":"sort-keys@5.0.0","_nodeVersion":"12.22.1","_npmVersion":"6.14.10","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"5d775f8ae93ecc29bc7312bbf3acac4e36e3c446","size":2601,"noattachment":false,"key":"/sort-keys/-/sort-keys-5.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/sort-keys/download/sort-keys-5.0.0.tgz"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/sort-keys_5.0.0_1618600736465_0.996820494032612"},"_hasShrinkwrap":false,"publish_time":1618600736621,"_cnpm_publish_time":1618600736621},"4.2.0":{"name":"sort-keys","version":"4.2.0","description":"Sort the keys of an object","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/sort-keys.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"engines":{"node":">=8"},"scripts":{"test":"xo && ava && tsd"},"keywords":["sort","object","keys","key","stable","deterministic","deep","recursive","recursively"],"dependencies":{"is-plain-obj":"^2.0.0"},"devDependencies":{"ava":"^2.2.0","tsd":"^0.7.4","xo":"^0.24.0"},"gitHead":"5b404fae29e3c60bf34d2d7a0065e8dc6bc04d23","bugs":{"url":"https://github.com/sindresorhus/sort-keys/issues"},"homepage":"https://github.com/sindresorhus/sort-keys#readme","_id":"sort-keys@4.2.0","_nodeVersion":"15.5.0","_npmVersion":"6.14.10","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"6b7638cee42c506fff8c1cecde7376d21315be18","size":2648,"noattachment":false,"key":"/sort-keys/-/sort-keys-4.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/sort-keys/download/sort-keys-4.2.0.tgz"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/sort-keys_4.2.0_1609312305095_0.12473893671027647"},"_hasShrinkwrap":false,"publish_time":1609312305350,"_cnpm_publish_time":1609312305350},"4.1.0":{"name":"sort-keys","version":"4.1.0","description":"Sort the keys of an object","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/sort-keys.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"engines":{"node":">=8"},"scripts":{"test":"xo && ava && tsd"},"keywords":["sort","object","keys","key","stable","deterministic","deep","recursive","recursively"],"dependencies":{"is-plain-obj":"^2.0.0"},"devDependencies":{"ava":"^2.2.0","tsd":"^0.7.4","xo":"^0.24.0"},"gitHead":"4bd07b0cdb3d6f0af2ab0b7e333bea262b4bfe95","bugs":{"url":"https://github.com/sindresorhus/sort-keys/issues"},"homepage":"https://github.com/sindresorhus/sort-keys#readme","_id":"sort-keys@4.1.0","_nodeVersion":"14.11.0","_npmVersion":"6.14.8","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"727edc12fee49ce482848db07369ec44e0f3e9f2","size":2596,"noattachment":false,"key":"/sort-keys/-/sort-keys-4.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/sort-keys/download/sort-keys-4.1.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/sort-keys_4.1.0_1602623620511_0.498304284369369"},"_hasShrinkwrap":false,"publish_time":1602623620643,"_cnpm_publish_time":1602623620643},"4.0.0":{"name":"sort-keys","version":"4.0.0","description":"Sort the keys of an object","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/sort-keys.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=8"},"scripts":{"test":"xo && ava && tsd"},"keywords":["sort","object","keys","key","stable","deterministic","deep","recursive","recursively"],"dependencies":{"is-plain-obj":"^2.0.0"},"devDependencies":{"ava":"^2.2.0","tsd":"^0.7.4","xo":"^0.24.0"},"gitHead":"a3d55abdfd8bdf82117d657118cb6774f4170e72","bugs":{"url":"https://github.com/sindresorhus/sort-keys/issues"},"homepage":"https://github.com/sindresorhus/sort-keys#readme","_id":"sort-keys@4.0.0","_nodeVersion":"10.16.0","_npmVersion":"6.9.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"56dc5e256637bfe3fec8db0dc57c08b1a2be22d6","size":2482,"noattachment":false,"key":"/sort-keys/-/sort-keys-4.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/sort-keys/download/sort-keys-4.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/sort-keys_4.0.0_1565864704278_0.010753726297067168"},"_hasShrinkwrap":false,"publish_time":1565864704466,"_cnpm_publish_time":1565864704466},"3.0.0":{"name":"sort-keys","version":"3.0.0","description":"Sort the keys of an object","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/sort-keys.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=8"},"scripts":{"test":"xo && ava && tsd"},"keywords":["sort","object","keys","key","stable","deterministic","deep","recursive","recursively"],"dependencies":{"is-plain-obj":"^2.0.0"},"devDependencies":{"ava":"^1.4.1","tsd":"^0.7.2","xo":"^0.24.0"},"gitHead":"70c831714c67670fc97e4c4fbc9049de6e3d6fbc","bugs":{"url":"https://github.com/sindresorhus/sort-keys/issues"},"homepage":"https://github.com/sindresorhus/sort-keys#readme","_id":"sort-keys@3.0.0","_nodeVersion":"8.16.0","_npmVersion":"6.9.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"fa751737e3da363ef80632d4fd78e324d661fe9a","size":2189,"noattachment":false,"key":"/sort-keys/-/sort-keys-3.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/sort-keys/download/sort-keys-3.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/sort-keys_3.0.0_1557130684213_0.7700247300394383"},"_hasShrinkwrap":false,"publish_time":1557130684347,"_cnpm_publish_time":1557130684347},"2.0.0":{"name":"sort-keys","version":"2.0.0","description":"Sort the keys of an object","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/sort-keys.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=4"},"scripts":{"test":"xo && ava"},"files":["index.js"],"keywords":["sort","object","keys","obj","key","stable","deterministic","deep","recursive","recursively"],"dependencies":{"is-plain-obj":"^1.0.0"},"devDependencies":{"ava":"*","xo":"*"},"gitHead":"956f1cedd4f0e7f2b58ca4324f5fb21f93cb7adf","bugs":{"url":"https://github.com/sindresorhus/sort-keys/issues"},"homepage":"https://github.com/sindresorhus/sort-keys#readme","_id":"sort-keys@2.0.0","_shasum":"658535584861ec97d730d6cf41822e1f56684128","_from":".","_npmVersion":"2.15.11","_nodeVersion":"4.8.3","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"658535584861ec97d730d6cf41822e1f56684128","size":2066,"noattachment":false,"key":"/sort-keys/-/sort-keys-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/sort-keys/download/sort-keys-2.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/sort-keys-2.0.0.tgz_1497046107604_0.3528045960702002"},"directories":{},"publish_time":1497046108583,"_hasShrinkwrap":false,"_cnpm_publish_time":1497046108583},"1.1.2":{"name":"sort-keys","version":"1.1.2","description":"Sort the keys of an object","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/sort-keys.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=0.10.0"},"scripts":{"test":"xo && mocha"},"files":["index.js"],"keywords":["sort","object","keys","obj","key","stable","deterministic","deep","recursive","recursively"],"dependencies":{"is-plain-obj":"^1.0.0"},"devDependencies":{"mocha":"*","xo":"*"},"gitHead":"daad509046075f30586f295eefa36bab18384eae","bugs":{"url":"https://github.com/sindresorhus/sort-keys/issues"},"homepage":"https://github.com/sindresorhus/sort-keys#readme","_id":"sort-keys@1.1.2","_shasum":"441b6d4d346798f1b4e49e8920adfba0e543f9ad","_from":".","_npmVersion":"2.15.0","_nodeVersion":"4.4.2","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"441b6d4d346798f1b4e49e8920adfba0e543f9ad","size":1993,"noattachment":false,"key":"/sort-keys/-/sort-keys-1.1.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/sort-keys/download/sort-keys-1.1.2.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/sort-keys-1.1.2.tgz_1463546673008_0.6780793990474194"},"directories":{},"publish_time":1463546673631,"_cnpm_publish_time":1463546673631,"_hasShrinkwrap":false},"1.1.1":{"name":"sort-keys","version":"1.1.1","description":"Sort the keys of an object","license":"MIT","repository":{"type":"git","url":"https://github.com/sindresorhus/sort-keys"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=0.10.0"},"scripts":{"test":"mocha"},"files":["index.js"],"keywords":["object","obj","keys","key","sort","stable","deterministic","deep","recursive","recursively"],"dependencies":{"is-plain-obj":"^1.0.0"},"devDependencies":{"mocha":"*"},"gitHead":"593116b1fa2f9a4acb76ca49d452050450226d1d","bugs":{"url":"https://github.com/sindresorhus/sort-keys/issues"},"homepage":"https://github.com/sindresorhus/sort-keys","_id":"sort-keys@1.1.1","_shasum":"a791c26071df66c356bf5dcad9cfb57a7b2f826e","_from":".","_npmVersion":"2.11.2","_nodeVersion":"0.12.5","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"a791c26071df66c356bf5dcad9cfb57a7b2f826e","size":1933,"noattachment":false,"key":"/sort-keys/-/sort-keys-1.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/sort-keys/download/sort-keys-1.1.1.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"publish_time":1437659399229,"_cnpm_publish_time":1437659399229,"_hasShrinkwrap":false},"1.1.0":{"name":"sort-keys","version":"1.1.0","description":"Sort the keys of an object","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/sort-keys.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=0.10.0"},"scripts":{"test":"mocha"},"files":["index.js"],"keywords":["object","obj","keys","key","sort","stable","deterministic","deep","recursive","recursively"],"dependencies":{"is-obj":"^1.0.0"},"devDependencies":{"mocha":"*"},"gitHead":"6d3a30b67e1b34c2f639711b5892909e58220e9c","bugs":{"url":"https://github.com/sindresorhus/sort-keys/issues"},"homepage":"https://github.com/sindresorhus/sort-keys#readme","_id":"sort-keys@1.1.0","_shasum":"ef24501898b1abf450c0344c95710cc354f2901e","_from":".","_npmVersion":"2.11.2","_nodeVersion":"0.12.5","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"ef24501898b1abf450c0344c95710cc354f2901e","size":1927,"noattachment":false,"key":"/sort-keys/-/sort-keys-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/sort-keys/download/sort-keys-1.1.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"publish_time":1436620137311,"_cnpm_publish_time":1436620137311,"_hasShrinkwrap":false},"1.0.0":{"name":"sort-keys","version":"1.0.0","description":"Sort the keys of an object","license":"MIT","repository":{"type":"git","url":"git://github.com/sindresorhus/sort-keys"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"http://sindresorhus.com"},"engines":{"node":">=0.10.0"},"scripts":{"test":"mocha"},"files":["index.js"],"keywords":["object","obj","keys","key","sort"],"devDependencies":{"mocha":"*"},"gitHead":"645a409d4f48cf7df2a270d33189c76cd0144117","bugs":{"url":"https://github.com/sindresorhus/sort-keys/issues"},"homepage":"https://github.com/sindresorhus/sort-keys","_id":"sort-keys@1.0.0","_shasum":"96d8a4314dc24728b66842a6bbb38759c1ca520f","_from":".","_npmVersion":"1.4.14","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"maintainers":[{"name":"sindresorhus","email":""}],"dist":{"shasum":"96d8a4314dc24728b66842a6bbb38759c1ca520f","size":1015,"noattachment":false,"key":"/sort-keys/-/sort-keys-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/sort-keys/download/sort-keys-1.0.0.tgz"},"directories":{},"publish_time":1407936386900,"_cnpm_publish_time":1407936386900,"_hasShrinkwrap":false},"0.1.0":{"name":"sort-keys","version":"0.1.0","description":"Sort the keys of an object","license":"MIT","repository":{"type":"git","url":"git://github.com/sindresorhus/sort-keys"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"http://sindresorhus.com"},"engines":{"node":">=0.10.0"},"scripts":{"test":"mocha"},"files":["index.js"],"keywords":["object","obj","keys","key","sort"],"devDependencies":{"mocha":"*"},"bugs":{"url":"https://github.com/sindresorhus/sort-keys/issues"},"homepage":"https://github.com/sindresorhus/sort-keys","_id":"sort-keys@0.1.0","_shasum":"aaae2d5563d6b8cf914215e9f65b7aea30cab469","_from":".","_npmVersion":"1.4.9","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"maintainers":[{"name":"sindresorhus","email":""}],"dist":{"shasum":"aaae2d5563d6b8cf914215e9f65b7aea30cab469","size":1013,"noattachment":false,"key":"/sort-keys/-/sort-keys-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/sort-keys/download/sort-keys-0.1.0.tgz"},"directories":{},"publish_time":1403961639025,"_cnpm_publish_time":1403961639025,"_hasShrinkwrap":false}},"readme":"# sort-keys\n\n> Sort the keys of an object\n\nUseful to get a deterministically ordered object, as the order of keys can vary between engines.\n\n## Install\n\n```sh\nnpm install sort-keys\n```\n\n## Usage\n\n```js\nimport sortKeys from 'sort-keys';\n\nsortKeys({c: 0, a: 0, b: 0});\n//=> {a: 0, b: 0, c: 0}\n\nsortKeys({b: {b: 0, a: 0}, a: 0}, {deep: true});\n//=> {a: 0, b: {a: 0, b: 0}}\n\nsortKeys({b: [{b: 0, a: 0}], a: 0}, {deep: true});\n//=> {a: 0, b: [{a: 0, b: 0}]}\n\nsortKeys({c: 0, a: 0, b: 0}, {\n\tcompare: (a, b) => -a.localeCompare(b)\n});\n//=> {c: 0, b: 0, a: 0}\n\nsortKeys([{b: 0, a: 2}], {deep: true});\n//=> [{a: 2, b: 0}]\n```\n\n## Advanced Usage with context\n\nThe `deep` and `ignoreKeys` options can receive a context object with detailed information about the current key being processed:\n\n```js\n// Ignore private keys only at root level\nsortKeys(data, {\n\tignoreKeys: ({key, depth}) => key.startsWith('_') && depth === 0\n});\n\n// Deep process only up to 3 levels, skip config paths\nsortKeys(data, {\n\tdeep: ({path, depth}) => depth < 3 && !path.includes('config')\n});\n\n// Complex path-based logic\nsortKeys(data, {\n\tdeep: ({path}) => !(path[0] === 'user' && path[1] === 'cache'),\n\tignoreKeys: ({path, key}) => (path.length === 1 && path[0] === 'metadata') || key.startsWith('_')\n});\n```\n\n## API\n\n### sortKeys(object, options?)\n\nReturns a new object with sorted keys.\n\nProperty descriptors are preserved, including accessors (get/set), and getters are not invoked or deep-processed. Circular references are supported and preserved.\n\n#### object\n\nType: `object | Array`\n\nWhen it's an object:\n- Only plain objects are deeply processed.\n- Only enumerable own string keys are considered; symbol and non-enumerable properties are ignored.\n\nWhen it's an array:\n- Array order is unchanged; holes in sparse arrays are preserved.\n- Elements may be deep-processed if `deep` enables it.\n- Extra enumerable properties on arrays are ignored.\n\n#### options\n\nType: `object`\n\n##### compare\n\nType: `Function`\n\n[Compare function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort) for sorting keys.\n\nIf omitted, remaining keys are sorted using the platform's default string sort.\n\n```js\nsortKeys(object, {\n\tcompare: (a, b) => b.localeCompare(a) // Reverse alphabetical\n});\n```\n\n##### deep\n\nType: `boolean | Function`\\\nDefault: `false`\n\nRecursively sort keys, including keys of objects inside arrays.\n\nOnly plain objects are sorted; other object types are left as-is. For arrays, deep processing applies to their elements.\n\nWhen a boolean:\n- `true`: Deep process all nested objects and arrays.\n- `false`: Only sort keys at the current level.\n\nWhen a function, it receives a context object and should return `true` to enable deep processing for that specific key-value pair:\n\n```js\nsortKeys(data, {\n\tdeep: ({key, value, path, depth}) => {\n\t\t// Only deep process up to 2 levels\n\t\tif (depth >= 2) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Skip deep processing of large arrays for performance\n\t\tif (Array.isArray(value) && value.length > 100) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Skip config objects entirely\n\t\tif (path.includes('config')) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t}\n});\n```\n\n##### ignoreKeys\n\nType: `string[] | Function`\\\nDefault: `[]`\n\nKeys to ignore when sorting. Ignored keys will appear first in their original order, followed by the sorted keys. Remaining keys are sorted by `compare`, or by default string sort if `compare` is not provided.\n\nCan be an array of key names:\n\n```js\nsortKeys({c: 0, _private: 1, a: 0, b: 0}, {ignoreKeys: ['_private']});\n//=> {_private: 1, a: 0, b: 0, c: 0}\n```\n\nOr a function that receives a context object:\n\n```js\nsortKeys(data, {\n\tignoreKeys: ({key, value, path, depth}) => {\n\t\t// Ignore private keys at root level\n\t\tif (key.startsWith('_') && depth === 0) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// Ignore metadata keys in user objects\n\t\tif (path[0] === 'user' && key === 'metadata') {\n\t\t\treturn true;\n\t\t}\n\n\t\t// Ignore empty objects\n\t\tif (typeof value === 'object' && Object.keys(value).length === 0) {\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t}\n});\n```\n\n**Note**: `ignoreKeys` only affects the ordering of object keys; it does not control deep processing, and array indices are not sorted or filtered. To prevent deep processing of specific values, use the `deep` function option.\n\n#### Context object\n\nWhen using functions for `deep` or `ignoreKeys`, they receive a context object with:\n\n- **`key`** (`string`): The current key being processed.\n- **`value`** (`any`): The value associated with the current key.\n- **`path`** (`string[]`): The full path to this key as an array of elements (for example, `['user', 'profile', 'name']`). Array indices are stringified (for example, `['items', '0', 'title']`).\n- **`depth`** (`number`): The current nesting depth (0 for root level).\n\n#### Path examples\n\n```js\nconst data = {\n\tuser: {\n\t\tprofile: {\n\t\t\tname: 'John'\n\t\t}\n\t},\n\titems: [\n\t\t{title: 'Item 1'},\n\t\t{title: 'Item 2'}\n\t]\n};\n\n// Paths generated during processing (as arrays):\n// ['user'] (depth: 0)\n// ['user', 'profile'] (depth: 1)\n// ['user', 'profile', 'name'] (depth: 2)\n// ['items'] (depth: 0)\n// ['items', '0'] (depth: 1)\n// ['items', '0', 'title'] (depth: 2)\n// ['items', '1'] (depth: 1)\n// ['items', '1', 'title'] (depth: 2)\n```\n\nNote: `path` is an array of elements with stringified array indices (for example, `['items', '0', 'title']`). If your key names include dots or special characters, this representation remains unambiguous.\n","_attachments":{},"homepage":"https://github.com/sindresorhus/sort-keys#readme","bugs":{"url":"https://github.com/sindresorhus/sort-keys/issues"},"license":"MIT"}