Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Deeply sort an object by its keys without mangling any arrays inside of it
CoffeeScript JavaScript Shell
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
src
.editorconfig
.gitignore
.npmignore
.travis.yml
Backers.md
Cakefile
History.md
LICENSE.md
README.md
example.js
package.json

README.md

Sort Object

Build Status NPM version Flattr this project

Returns a copy of an object, sorted deeply by its keys, without mangling any arrays inside of it

Install

Backend

  1. Install Node.js
  2. npm install --save sortobject

Frontend

  1. See Browserify

Usage

var sortObject = require('sortobject');
var fixture = {
    "c": true,
    "a": true,
    "b": null,
    "d": [
        {
            "c": true,
            "a": true,
            "b": null
        },
        {
            "c": true,
            "a": true,
            "b": null,
            "d": [
                {
                    "c": true,
                    "a": true,
                    "b": null
                }
            ]
        }
    ]
};
var actual = sortObject(fixture);
console.log(JSON.stringify(actual,null,4));  /* {
    "a": true,
    "b": null,
    "c": true,
    "d": [
        {
            "a": true,
            "b": null,
            "c": true
        },
        {
            "a": true,
            "b": null,
            "c": true,
            "d": [
                {
                    "a": true,
                    "b": null,
                    "c": true
                }
            ]
        }
    ]
} */

History

You can discover the history inside the History.md file

Backers

Check out the Backers.md file to discover all the amazing people who financially supported the development of this project.

License

Licensed under the incredibly permissive MIT License
Copyright © 2013+ Bevry Pty Ltd

Something went wrong with that request. Please try again.