JSON Deep Sort is a comprehensive package that provides flexible sorting of JSON objects by keys. This TypeScript-written package can handle deeply nested objects and arrays, and offers both synchronous and asynchronous operations.
Using npm:
npm install @tamtamchik/json-deep-sort
Using yarn:
yarn add @tamtamchik/json-deep-sort
Import JSON Deep Sort in your TypeScript file:
import { sort } from '@tamtamchik/json-deep-sort';
Here is an example of sorting a JSON object:
let data = {
b: 'b',
a: 'a',
c: {
d: 'd',
c: 'c',
a: 'a',
b: 'b'
}
};
let sortedData = sort(data, true);
// { a: 'a', b: 'b', c: { a: 'a', b: 'b', c: 'c', d: 'd' } }
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
JSON Deep Sort is MIT licensed.