MSP-3203 create objectUtils
This commit is contained in:
1 parent
3ed8626c81
commit
a8fb23b3d1
1 file changed
+19
@@ -0,0 +1,19 @@
|
||||
const sortObject = (obj: any): any => {
|
||||
if (typeof obj !== 'object' || obj === null) {
|
||||
return obj
|
||||
}
|
||||
|
||||
if (Array.isArray(obj)) {
|
||||
return obj.map(sortObject)
|
||||
}
|
||||
|
||||
const sorted: any = {}
|
||||
Object.keys(obj)
|
||||
.sort()
|
||||
.forEach((key) => {
|
||||
sorted[key] = sortObject(obj[key])
|
||||
})
|
||||
return sorted
|
||||
}
|
||||
|
||||
export { sortObject }
|
||||
Reference in new issue
Block a user