I'm currently developing an Angular 9 application focused on covid-19 cases, and I need to arrange my objects by the value of nested objects.
Here is the dataset that I want to organize alphabetically based on the 'state' field values: state: Kerala, state: Haryana;
{
"history": [
{
"day": "2020-03-14",
"total": {
"confirmed": 84
},
"statewise": [
{
"state": "Kerala",
"confirmed": 19
},
{
"state": "Assam",
"confirmed": 14
}
]
},
{
"day": "2020-03-15",
"total": {
"confirmed": 104
},
"statewise": [
{
"state": "Kerala",
"confirmed": 119
},
{
"state": "Assam",
"confirmed": 114
}
]
}
]
}
So, after sorting, I expect my data to be like this:
Sorted Data
{
"history": [
{
"day": "2020-03-14",
"total": {
"confirmed": 84
},
"statewise": [
{
"state": "Assam",
"confirmed": 14
},
{
"state": "Kerala",
"confirmed": 19
}
]
},
{
"day": "2020-03-15",
"total": {
"confirmed": 104
},
"statewise": [
{
"state": "Assam",
"confirmed": 114
},
{
"state": "Kerala",
"confirmed": 119
}
]
}
]
}
You can access my API data through this link: API data API data link. I've spent two days trying to implement solutions similar to this suggested on Stack Overflow answer, but I'm still unsure about the next steps. Any assistance would be greatly appreciated.