deep-sort-object
Version:
Sorts object by its keys
68 lines (48 loc) • 1.81 kB
Markdown
[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency status][david-dm-image]][david-dm-url] [![Dev Dependency status][david-dm-dev-image]][david-dm-dev-url]
[]:https://npmjs.org/package/deep-sort-object
[]:http://img.shields.io/npm/dm/deep-sort-object.svg
[]:http://img.shields.io/npm/v/deep-sort-object.svg
[]:https://travis-ci.org/IndigoUnited/js-deep-sort-object
[]:http://img.shields.io/travis/IndigoUnited/js-deep-sort-object/master.svg
[]:https://david-dm.org/IndigoUnited/js-deep-sort-object
[]:https://img.shields.io/david/IndigoUnited/js-deep-sort-object.svg
[]:https://david-dm.org/IndigoUnited/js-deep-sort-object#info=devDependencies
[]:https://img.shields.io/david/dev/IndigoUnited/js-deep-sort-object.svg
Simple module to sort objects recursively by its keys.
`$ npm install deep-sort-object` - `NPM`
`$ bower install deep-sort-object` - `bower`
The browser file is named `index.umd.js` which supports CommonJS, AMD and globals (`deepForEach`).
If you want to run this module on old browsers, you must include [es5-shim](https://github.com/es-shims/es5-shim).
## Usage
The example bellow is based on `nodejs`.
```js
var sortobject = require('deep-sort-object');
sortobject({
'z': 'foo',
'b': 'bar',
'a': [
{
'z': 'foo',
'b': 'bar'
}
]
});
/*
{
'a': [
{
'b': 'bar',
'z': 'foo'
}
],
'b': 'bar',
'z': 'foo'
});
*/
```
`$ npm test`
Released under the [MIT License](http://www.opensource.org/licenses/mit-license.php).