Skip to content

Commit

Permalink
Fix issue where objects nested in arrays would not have sorted keys
Browse files Browse the repository at this point in the history
  • Loading branch information
diurnalist committed Jul 17, 2014
1 parent 8cd6a4f commit 2b83332
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ function main (args) {

// from http://stackoverflow.com/questions/1359761/sorting-a-json-object-in-javascript
function sortObject(o) {
if (Object.prototype.toString.call(o) !== '[object Object]') {
if (Array.isArray(o)) {
return o.map(sortObject);
} else if (Object.prototype.toString.call(o) !== '[object Object]') {
return o;
}

Expand Down

0 comments on commit 2b83332

Please sign in to comment.