Say I have an array such as below, what would the best method be to separate these into individual arrays if the times overlap? I’m using moment but am a bit unsure of how to tackle this.
I know I have to sort the array initially.
data:
const timetable = [
{ class: 'one', start: '2021-11-16T09:00:00', end: '2021-11-16T10:00:00' },
{ class: 'two', start: '2021-11-16T010:00:00', end: '2021-11-16T11:00:00' },
{ class: 'three', start: '2021-11-16T09:00:00', end: '2021-11-16T10:00:00' },
];
expected:
const timetable = [
[
{ class: 'one', start: '2021-11-16T09:00:00', end: '2021-11-16T10:00:00' },
{ class: 'two', start: '2021-11-16T010:00:00', end: '2021-11-16T11:00:00' },
],
[
{
class: 'three',
start: '2021-11-16T09:00:00',
end: '2021-11-16T10:00:00',
},
],
];