I have an array of objects :
myData = [{
name: "",
lastName:"",
moreData: [{
left: 5,
data: '',
},
{
left: 3,
data: '',
}
]
},
{
name: "",
lastName:"",
moreData: [{
left: 8,
data: '',
},
{
left: 4,
data: '',
}
]
}
],
I need the to sort the outer objects (main array) based on left:, descending order, so I would have such outcome:
myData = [{
name: "",
lastName: "",
moreData: [{
left: 8,
data: '',
}]
},
{
name: "",
lastName: "",
moreData: [{
left: 5,
data: '',
}]
},
{
name: "",
lastName: "",
moreData: [{
left: 4,
data: '',
}]
},
{
name: "",
lastName: "",
moreData: [{
left: 3,
data: '',
}]
}
]
or is there a way to have only moreData sorted regardless of what object it belongs to, and save that and then be able to identify whose user the moreData belongs to ?
I need to sort the array based on a column that has multiple objects inside the its array. so the outer object will be repeated Using JS, can even use Lodash if necessary. Any guidance?