import { isObject } from './is-object' ; export function deepSortObject ( item ) { if ( ! isObject ( item ) ) { throw new Error ( 'Only objects can be sorted with this method' ) ; } return recursiveSortObject ( item ) ; } function recursiveSortObject ( item ) { return Object . entries ( item ) . sort ( ) . reduce ( ( acc , [ key , value ] ) => { if ( isObject ( value ) ) { acc [ key ] = recursiveSortObject ( value ) ; } else { acc [ key ] = value ; } return acc ; } , { } ) ; }