{"id":26234285,"url":"https://github.com/tamtamchik/json-deep-sort","last_synced_at":"2026-04-15T00:02:17.467Z","repository":{"id":171005626,"uuid":"647289298","full_name":"tamtamchik/json-deep-sort","owner":"tamtamchik","description":"A comprehensive utility for sorting JSON objects by keys.","archived":false,"fork":false,"pushed_at":"2025-08-10T12:46:27.000Z","size":269,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-09-19T15:18:27.500Z","etag":null,"topics":["json","json-tools","json-utilities","keysorting","sorting","typescript-library"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tamtamchik.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-30T13:12:19.000Z","updated_at":"2025-08-19T14:17:17.000Z","dependencies_parsed_at":"2024-01-14T17:02:47.351Z","dependency_job_id":"102716d1-b1fe-4c95-a134-c9988ad9fd21","html_url":"https://github.com/tamtamchik/json-deep-sort","commit_stats":{"total_commits":19,"total_committers":1,"mean_commits":19.0,"dds":0.0,"last_synced_commit":"66c4837c7ddec5df5bb1cc9a25d58b86becbd132"},"previous_names":["tamtamchik/json-deep-sort"],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/tamtamchik/json-deep-sort","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tamtamchik%2Fjson-deep-sort","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tamtamchik%2Fjson-deep-sort/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tamtamchik%2Fjson-deep-sort/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tamtamchik%2Fjson-deep-sort/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tamtamchik","download_url":"https://codeload.github.com/tamtamchik/json-deep-sort/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tamtamchik%2Fjson-deep-sort/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31820369,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-14T18:05:02.291Z","status":"ssl_error","status_checked_at":"2026-04-14T18:05:01.765Z","response_time":153,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["json","json-tools","json-utilities","keysorting","sorting","typescript-library"],"created_at":"2025-03-13T01:29:50.729Z","updated_at":"2026-04-15T00:02:17.424Z","avatar_url":"https://github.com/tamtamchik.png","language":"TypeScript","funding_links":["https://www.buymeacoffee.com/tamtamchik"],"categories":[],"sub_categories":[],"readme":"# JSON Deep Sort\n\n[![Buy Me A Coffee][ico-coffee]][link-coffee]\n[![Latest Version on NPM][ico-version]][link-npm]\n[![Scrutinizer build][ico-scrutinizer-build]][link-scrutinizer]\n[![Scrutinizer quality][ico-scrutinizer-quality]][link-scrutinizer]\n[![Scrutinizer coverage][ico-scrutinizer-coverage]][link-scrutinizer]\n[![Software License][ico-license]](LICENSE)\n[![Total Downloads][ico-downloads]][link-downloads]\n\nJSON Deep Sort is a powerful and versatile TypeScript package designed for efficient sorting of JSON objects by keys. It offers:\n\n- Comprehensive handling of deeply nested objects and arrays\n- Flexible sorting options, including ascending and descending order\n- Support for both synchronous and asynchronous operations\n- Preservation of non-sortable objects (e.g., Date, RegExp, Function)\n- Lightweight implementation with zero dependencies\n\nWhether you're working with simple flat objects or complex nested structures, JSON Deep Sort provides a reliable solution for organizing your data.\n\n## Installation\n\nUsing npm:\n\n```shell\nnpm install @tamtamchik/json-deep-sort\n```\n\nUsing yarn:\n\n```shell\nyarn add @tamtamchik/json-deep-sort\n```\n\n## Usage\n\nImport JSON Deep Sort in your TypeScript file:\n\n```typescript\nimport { sort } from '@tamtamchik/json-deep-sort';\n```\n\nHere is an example of sorting a JSON object:\n\n```typescript\n// Example 1: Sorting a simple object\nconst simpleData = { b: 'b', a: 'a', c: 'c' };\nconsole.log(sort(simpleData));\n// Output: { a: 'a', b: 'b', c: 'c' }\n\n// Example 2: Sorting a nested object\nconst nestedData = {\n  b: 'b',\n  a: 'a',\n  c: { d: 'd', c: 'c', a: 'a', b: 'b' },\n};\nconsole.log(sort(nestedData));\n// Output: { a: 'a', b: 'b', c: { a: 'a', b: 'b', c: 'c', d: 'd' } }\n\n// Example 3: Sorting an array of objects\nconst arrayData = [\n  { b: 'b', a: 'a' },\n  { d: 'd', c: 'c' },\n];\nconsole.log(sort(arrayData));\n// Output: [{ a: 'a', b: 'b' }, { c: 'c', d: 'd' }]\n\n// Example 4: Sorting in descending order\nconst descendingData = { a: 'a', c: 'c', b: 'b' };\nconsole.log(sort(descendingData, false));\n// Output: { c: 'c', b: 'b', a: 'a' }\n\n// Example 5: Handling mixed data types\nconst mixedData = {\n  b: [3, 1, 2],\n  a: { z: 'z', y: 'y' },\n  c: new Date('2023-01-01'),\n};\nconsole.log(sort(mixedData));\n// Output: { a: { y: 'y', z: 'z' }, b: [3, 1, 2], c: Date('2023-01-01') }\n\n// Example 6: Sorting arrays of primitives\nconst primitiveArrayData = ['b', 'a', 'c'];\nconsole.log(sort(primitiveArrayData, true, true));\n// Output: ['a', 'b', 'c']\n```\n\n## API Reference\n\n### `sort(data, ascending?, sortPrimitiveArrays?)`\n\nSorts a JSON object or array by keys in a specified order.\n\n**Parameters:**\n\n- `data` (required): The data to sort. Can be an object, array, or primitive value.\n- `ascending` (optional): Boolean flag to determine sort order. Defaults to `true` (ascending).\n- `sortPrimitiveArrays` (optional): Boolean flag to enable sorting of arrays containing primitive values (strings, numbers, booleans). Defaults to `false` to maintain backward compatibility.\n\n**Returns:** The sorted data with the same structure and type as the input.\n\n**Note:** When `sortPrimitiveArrays` is `false` (default), arrays of primitives are not modified, preserving the original behavior. When `true`, primitive arrays are sorted according to the `ascending` parameter.\n\n## Contributing\n\nPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.\n\n## License\n\nJSON Deep Sort is [MIT licensed](./LICENSE).\n\n[ico-coffee]: https://img.shields.io/badge/Buy%20Me%20A-Coffee-%236F4E37.svg?style=flat-square\n[ico-version]: https://img.shields.io/npm/v/@tamtamchik/json-deep-sort.svg?style=flat-square\n[ico-license]: https://img.shields.io/npm/l/@tamtamchik/json-deep-sort.svg?style=flat-square\n[ico-downloads]: https://img.shields.io/npm/dt/@tamtamchik/json-deep-sort.svg?style=flat-square\n[ico-scrutinizer-build]: https://img.shields.io/scrutinizer/build/g/tamtamchik/json-deep-sort/main.svg?style=flat-square\n[ico-scrutinizer-quality]: https://img.shields.io/scrutinizer/quality/g/tamtamchik/json-deep-sort/main.svg?style=flat-square\n[ico-scrutinizer-coverage]: https://img.shields.io/scrutinizer/coverage/g/tamtamchik/json-deep-sort/main.svg?style=flat-square\n[link-coffee]: https://www.buymeacoffee.com/tamtamchik\n[link-npm]: https://www.npmjs.com/package/@tamtamchik/json-deep-sort\n[link-downloads]: https://www.npmjs.com/package/@tamtamchik/json-deep-sort\n[link-scrutinizer]: https://scrutinizer-ci.com/g/tamtamchik/json-deep-sort/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftamtamchik%2Fjson-deep-sort","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftamtamchik%2Fjson-deep-sort","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftamtamchik%2Fjson-deep-sort/lists"}