I have an array of objects and I want to sort it by date (in this case it's the property with occurredAt
in it's name). Here is the array:
const arr = [
{
EmailCampaignEvents.campaignRef: "test6example1",
EmailCampaignEvents.campaignSentAt: "2021-04-09T13:19:24.000",
EmailCampaignEvents.customerRef: "Customer/activityTest10",
EmailCampaignEvents.emailRef: "Email/9374eaee0713f36a247b0d0c863e920b",
EmailCampaignEvents.eventType: "delivery",
EmailCampaignEvents.occurredAt: "2021-04-09T13:19:25.000",
},
{
Events.occurredAt: "2017-01-11T17:29:57.000",
Events.productRef: "Event/201-13",
Events.relatedEntityRefFlat: "Customer/201-5645307",
Events.transactionCurrency: "SEK",
Events.transactionItemCount: "4",
Events.transactionItemPrice: "235.85",
Events.type: "as.commerce.transaction.completed",
relatedEventName: "Hammarby-Östersunds FK",
},
{
Events.occurredAt: "2018-01-11T17:29:57.000",
Events.productRef: "Event/201-13",
Events.relatedEntityRefFlat: "Customer/201-5645307",
Events.transactionCurrency: "SEK",
Events.transactionItemCount: "2",
Events.transactionItemPrice: "135.85",
Events.type: "as.commerce.transaction.completed",
relatedEventName: "Hammarby-Östersunds FK",
},
];
Note that in the first object I have EmailCampaignEvents.occurredAt
and in the rest two I have a property like this Events.occurredAt
. Is it possible to sort this array somehow? Any example will be appreciated!