I have a list of strings in an NSMutableArray, and I want to sort them into alphabetical order before displaying them in my table view.
How can I do tha
It's easy to get the ascending order. Follow the bellow steps,,,
Model 1 :
NSSortDescriptor *sortDesc = [NSSortDescriptor sortDescriptorWithKey:@"name" ascending:YES];
sortedArray=[yourArray sortedArrayUsingDescriptors:@[sortDesc]];
If you want the sorting to be case insensitive, you would need to set the descriptor like this,,
Model 2 :
NSSortDescriptor * sortDesc = [NSSortDescriptor sortDescriptorWithKey:@"name" ascending:YES selector:@selector(caseInsensitiveCompare:)];
sortedArray=[yourArray sortedArrayUsingDescriptors:@[sortDesc]];