I have an array of objects that looks like the following:
[
{
"node_name": "node1",
"external": "external_node1",
"status": "online",
"Date": "2022-05-26 08:20:27.022313"
},
{
"node_name": "node2",
"external": "external_node2",
"status": "offline",
"Date": "2022-05-26 20:20:27.022313"
},
{
"node_name": "node3",
"external": "external_node3",
"status": "online",
"Date": "2022-05-26 08:20:27.022313"
},
{
"node_name": "node4",
"external": "external_node4",
"status": "online",
"Date": "2022-05-26 20:20:27.022313"
}
]
Using JavaScript, how would I 'group' and insert into its own array, all of the objects that have matching Date
values?
For example, node1
& node3
both have "2022-05-26 08:20:27.022313"
as its Date
value, as well as node2
& node4
having the same Date
value.
How would I sort these objects out and insert them into one array if the Date
values matched?