How can I sort an array filled with [UIFont familyNames]
into alphabetical order?
The other answers provided here mention using @selector(localizedCaseInsensitiveCompare:)
This works great for an array of NSString, however if you want to extend this to another type of object, and sort those objects according to a 'name' property, you should do this instead:
NSSortDescriptor *sort = [NSSortDescriptor sortDescriptorWithKey:@"name" ascending:YES];
sortedArray=[anArray sortedArrayUsingDescriptors:@[sort]];
Your objects will be sorted according to the name property of those objects.
If you want the sorting to be case insensitive, you would need to set the descriptor like this
NSSortDescriptor *sort = [NSSortDescriptor sortDescriptorWithKey:@"name" ascending:YES selector:@selector(caseInsensitiveCompare:)];