I'm facing a challenge where I need to iterate over an array of arrays structure to filter out duplicate datetime string values and then store the unique datetime string values in a new array while ensuring they are sorted. My attempt at using a nested forEach()
method failed as it wasn't working as expected.
This is the array of arrays structure:
arr =[
["some_value", "2016-11-23 18:11", 1]
["some_value", "2016-11-23 18:01", 1]
["some_value", "2016-11-23 18:01", 2]
["some_value", "2016-11-23 18:01", 1]
["some_value", "2016-11-23 18:22", 1]
["some_value", "2016-11-23 18:23", 1]
["some_value", "2016-11-23 18:25", 1]
["some_value", "2016-11-23 18:24", 3]
["some_value", "2016-11-23 18:26", 1]
["some_value", "2016-11-23 18:27", 1]
];
The desired result:
res = ["2016-11-23 18:01",
"2016-11-23 18:11",
"2016-11-23 18:22",
"2016-11-23 18:23",
"2016-11-23 18:24",
"2016-11-23 18:25",
"2016-11-23 18:26",
"2016-11-23 18:27"];
I would appreciate any guidance or tips on how to approach this issue effectively.