Package Exports
- object-array-sorter
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (object-array-sorter) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
object-array-sorter
=========
A small library that recursively sort the array properties in a given object. This could be helpful when you want to compare two json object/files.
Installation
npm install object-array-sorter
Usage
Note: The sorter utility has a default sort comparator which will sort the array values for primitive types (
string,number), and it also allows you to provide a custom comparator used to sort complex object elements.
const objectArraySorter = require('object-array-sorter');
let obj = {
a: "0",
b: {
e: [5, 7, 3],
f: ['tiger', 'cat', 'dog', 'horse']
},
c: [5, 2, 9]
};
objectSorter(obj);
console.log(JSON.stringify(obj, null, 2));
Output should be
{
a: "0",
b: {
e: [3, 5, 7],
f: ['cat', 'dog', 'horse', 'tiger']
},
c: [2, 5, 9]
}Tests
npm test
LICENSE
MIT