1'use strict' 2var sortedObject = require('sorted-object') 3 4module.exports = function deepSortObject (obj) { 5 if (obj == null || typeof obj !== 'object') return obj 6 if (obj instanceof Array) { 7 return obj.map(deepSortObject) 8 } 9 obj = sortedObject(obj) 10 Object.keys(obj).forEach(function (key) { 11 obj[key] = deepSortObject(obj[key]) 12 }) 13 return obj 14} 15