I have an array of UNNotificationRequest. I want to sort them by nextTriggerDate.
As far as I understand it, I would sort the array using array.sorted(by:predicate)
let sortedNotifications = notificationRequests.sorted(by: 
{ $0.trigger.nextTriggerDate?.compare($1.trigger.nextTriggerDate!) == .orderedAscending })
However, the problem is .trigger doesn't have a nextTriggerDate property.
In order to obtain nextTriggerDate, I have to extract the trigger and cast it into UNCalendarNotificationTrigger. Which as far as I know, can't be done in a predicate.
Any thoughts?
 
                        
You can create
TupleWith UNNotificationRequest and nextTriggerDate(UNNotificationRequest,nextTriggerDate)