I am having a strange problem with the Array.sort () function. He cannot accept an abbreviated closure. Xcode complains about the following message when using abbreviated closure: Cannot invoke 'sort' with an argument list of type '((_, _) -> _)' But it works with a longer form of the same closure.
var names = ["Al", "Mike", "Clint", "Bob"] // This `sort()` function call fails: names.sort { $0.localizedCaseInsensitiveCompare($1) == .OrderedAscending } // This `sort()` function call works: names.sort { (first: String, second: String) in return first.localizedCaseInsensitiveCompare(second) == .OrderedAscending }
To make things redundant, if I first use a long closing form and then sort again using the shortened form, it works great!
var names = ["Al", "Mike", "Clint", "Bob"]
So, the best scenario, I am doing something wrong and finding out something. In the worst case, this is just a silly mistake with Xcode or Swift.
Any ideas?
source share