I want the Swift version of this code:
NSArray *sortedNames = [names sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)];
If you want to sort your array in ascending order then use below syntax:
var arrayName = sorted(arrayName, <)
as the sorted() is the predefined function in swift and < is used to indicate that the array should be sorted in ascending order. If you want to sort the array in descending order then simply replace < with > as I have shown below:
var arrayName = sorted(arrayName, >)