You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

13 lines
362 B

'use strict'
var sortedObject = require('sorted-object')
module.exports = function deepSortObject (obj, sortBy) {
if (obj == null || typeof obj !== 'object') return obj
if (obj instanceof Array) return obj.sort(sortBy)
obj = sortedObject(obj)
Object.keys(obj).forEach(function (key) {
obj[key] = deepSortObject(obj[key], sortBy)
})
return obj
}