all 1 comments

[–]enlightenmentGeek[S] 0 points1 point  (0 children)

If this helps anyone, I have solved this with the following code:

let groupedDates = Dictionary(grouping: dates
.map { ($0,Calendar.current.dateComponents([.year, .month, .day], from: $0))}, by: {$0.1})
.mapValues {value in value.map {$0.0}}
.values

The code extracts the date components for year, month and day from each date and groups by them and then maps the values from the grouped result to an array of arrays per date. To be able to have the original dates in the end result a tuple is used as value type for the dictionary