I have some array like

`0: [id: '1',department: 'xyz',date: '10-10-2019',time: '12:50']`

`1: [id: '1',department: 'xyz',date: '11-10-2019',time: '10:30']`

`2: [id: '2',department: 'abc',date: '09-09-2019',time: '09:50']`

`3: [id: '2',department: 'abc',date: '07-07-2019',time: '03:20']`

I want them to be merged according to the `id` and `department`

so the `0` and `1` array will be merged together and the output should be something like

`0:[id: '1',department: 'xyz',[[date: '10-10-2019',time: '12:50'],[date: '11-10-2019',time: '10:30']]]`

and the `2` and `3` array will be merged together and the output should be something like

`1:[id: '2',department: 'abc',[[date: '09-09-2019',time: '09:50'],[date: '07-07-2019',time: '03:20']]]`

how can I do it?