i have the data structure like below,
const items = {
id: '1',
Orders: [
{
id: '1',
title: 'Order1',
startDate: "2019-08-13T00:00:00.000Z",
status: 'new',
}
{
id: '2',
title: 'Order2',
startDate: "2020-08-13T00:00:00.000Z",
status: 'done',
}
],
subItems: [
{
id: '1',
Orders: [
{
id: '1',
title: 'subitem-order1',
status: 'new',
startDate: '2019-08-13T00:00:00.000Z',
}
{
id: '2',
title: 'subitem-order2',
status: 'new',
startDate: '2020-08-13T00:00:00.000Z',
}
]
}
]
}
I want to order the orders by startdate in ascending order and subitem orders by startdate in ascending order.
so the output should be something like below,
const items = {
orders: [
{
id: '2',
title: 'Order2',
startDate: "2020-08-13T00:00:00.000Z",
status: 'done',
},
{
id: '1',
title: 'Order1',
startDate: "2019-08-13T00:00:00.000Z",
status: 'new',
},
]
subItems: [
{
id: '2',
title: 'subitem-order2',
status: 'new',
startDate: '2020-08-13T00:00:00.000Z',
},
{
id: '1',
title: 'Order1',
startDate: "2019-08-13T00:00:00.000Z",
status: 'new',
},
]
}
How can i group the orders in ascending order based on their startdate and subitems orders in ascending order based on their startdate. could someone help me with this. thanks.