var a = [
{
"subObj1": {
"key1":10722905,
"key2":"0080817626"
},
"outerKey1":"abcd",
"outerKey2":"defg"
},
{
"subObj1": {
"key1":123456,
"key2":"0987654"
},
"outerKey1":"pqrs",
"outerKey2":"ased"
}
]
i need to sort this array of object using key1 and outerkey1 both separately. That logic is already implemented.
_.sortBy(a,'outerKey1') -> this is working fine.
_.sortBy(a,'key1') -> this is not working.
_.sortBy(a,'subObj1.key1') -> this is also not working.
Is there any way to sort this array of objects with inner key of object like key1 or key2 using lodash _.sortBy function?
a.sort((a,b)=> a.subObj1.key1 - b.subObj1.key1)