I'm trying to sort contacts array by severity
var contacts: [Contact]? if let customer = CoreDataAccess.sharedInstance.getSavedCustomer() { //Cast from NSSet to [Contact] self.contacts = customer.contacts.allObjects as? [Contact] self.contacts!.sort({$0.severity < $1.severity}) //error }
Compiler error in the marked line with the following message:
Cannot invoke 'sort' with an argument list of type '((_, _) -> _)'
I am not sure what I am doing wrong, because it works the same in another file. If this helps explain, the above code crashes when working on the WatchKit interface, but not when using it on iOS.
EDIT: NSNumber is NSNumber
source share