Skip to content

Commit

Permalink
Merge pull request zaach#49 from diurnalist/feature/sort-arrays
Browse files Browse the repository at this point in the history
Fix issue where objects nested in arrays would not have sorted keys
  • Loading branch information
zaach committed Aug 12, 2014
2 parents 8cd6a4f + 2b83332 commit 957bf60
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 957bf60

Please sign in to comment.