I have two lists of objects as outlined below. I want to combine them by the FormattedDate such that the OrderSum is added together.
I can think of a brute-force way to do this by iterating over list one, and for each iteration, iterating the entire list two, basically a nested loop, but that seems inefficient as I have to do it over lists of 20-30 items.
Thank you!
List 1
[
{
"___class": "Orders",
"OrderSum": 1115,
"FormattedDate": "10/4/2022",
"objectId": "2452620B-E2A4-4CE7-822C-DA2C9664A6B9"
},
{
"___class": "Orders",
"OrderSum": 693,
"FormattedDate": "10/5/2022",
"objectId": "5EFC1C85-21D2-4445-BCD6-2A9FD0F87951"
},
{
"___class": "Orders",
"OrderSum": 24,
"FormattedDate": "10/6/2022",
"objectId": "31ED6957-35A1-4C6E-85F6-33F451F52E3C"
}
]
List 2
[
{
"___class": "Orders",
"OrderSum": 25,
"FormattedDate": "10/5/2022",
"objectId": "648CBF6C-8638-4625-B10A-3DCA84FA77A7"
}
]
Output List
[
{
"___class": "Orders",
"OrderSum": 1115,
"FormattedDate": "10/4/2022",
"objectId": "2452620B-E2A4-4CE7-822C-DA2C9664A6B9"
},
{
"___class": "Orders",
"OrderSum": 718, ***** this value was updated *****
"FormattedDate": "10/5/2022",
"objectId": "5EFC1C85-21D2-4445-BCD6-2A9FD0F87951"
},
{
"___class": "Orders",
"OrderSum": 24,
"FormattedDate": "10/6/2022",
"objectId": "31ED6957-35A1-4C6E-85F6-33F451F52E3C"
}
]