I have the following Object:
const object = {
"9c8vDTruRDPi937aHMMz":{
name: "item1",
createdAt: {
seconds: 1582227276,
nanoseconds: 68000000
}
},
"rAexYu2rAz0AEnD77x5p":{
name: "item2",
createdAt: {
seconds: 1582227577,
nanoseconds: 922000000
}
}
}
And would like to sort it depending on createdAt.seconds and keeping it as an object.
For example, the return value would be (if sorting depending on seconds and Desc):
const sortedByDateObject = {
"rAexQu3rdm0AEnD77x5p":{
name: "item2",
createdAt: {
seconds: 1582227577,
nanoseconds: 922000000
}
},
"9c8vDGryRSZi817aHMMz":{
name: "item1",
createdAt: {
seconds: 1582227276,
nanoseconds: 68000000
}
}
}
Know how to sort arrays with lodash, but not this kind of complex task with nested objects.
Any help is much appreaciated :)