How to alphabetically sort a UITableView section?

I have a partitioned UITableView with 3 categories. I am using this code:

NSArray *arrayOne = [NSArray arrayWithObjects: @"one", @"two", "three", "four", nil]; NSDictionary *dictOne = [NSDictionary dictionaryWithObject:arrayOne forKey:@"Elements"]; 

for each category.

How can I sort them alphabetically? I read a few answers here, but I didn't find out anything.

If I use the code in this answer Method of sorting custom objects alphabetically in a UITableView , this will not work. I have a code:

 [listObjects addObject:dictOne]; 

and if I put

 [listOfTitles sortUsingDescriptors:[NSArray arrayWithObject:titleSorter]; 

This does not work.

Any help appreciated

+4
source share
1 answer
 NSArray *arrayOne = [NSArray arrayWithObjects: @"one", @"two", "three", "four", nil]; NSArray *sortedArray = [arrayOne sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)]; NSDictionary *dictOne = [NSDictionary dictionaryWithObject:sortedArray forKey:@"Elements"]; 
+9
source

All Articles