I'm implementing an app where i need to show a tableView. tableView needs to dispaly json data and have alphabetical search on the right side by clicking on any letter it needs to show data starting with that letter. I've implemented the vertical alphabet search and when user clicks on any letter it takes user to that particular section. But the problem is my json data is not getting sorted.
Here is my code for this. // Here exhibitorArray contains all the info to populate data in tableView.
NSSortDescriptor *sort = [NSSortDescriptor sortDescriptorWithKey:@"serverData" ascending:YES];
NSArray *sortedArray = [serverData sortedArrayUsingDescriptors:[NSArray arrayWithObject:sort]];
NSLog(@"Sorted Array:%@",sortedArray);
答案 0 :(得分:0)
NSArray *unsortedStrings = @[@"Lamborghini", @"Lamborghini", @"InStyle",@"HSBC",@"Heineken"];
NSLog (@"unsorted = %@",unsortedStrings);
NSArray *sortedStrings =[unsortedStrings sortedArrayUsingSelector:@selector(compare:)];
NSLog (@"sorted = %@",sortedStrings);
unsorted = ( Lamborghini, Lamborghini, InStyle, HSBC, Heineken )
sorted = ( HSBC, Heineken, InStyle, Lamborghini, Lamborghini )