Reputation: 1
I would like to sort the nsarray record as the following:
NSArray * name = [entityArray valueForKey:@"Name"];
using NSSortDescriptor , but it does not show ascending.
Upvotes: 0
Views: 97
Reputation:
Add the following in your fetch record function.
NSSortDescriptor *sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"column2sort" ascending:YES];
NSArray *sortDescriptorArray = [NSArray arrayWithObjects: sortDescriptor, nil];
[fetchRequest setSortDescriptors:sortDescriptorArray];
Upvotes: 1
Reputation: 826
NSSortDescriptor *lastNameDescriptor = [[NSSortDescriptor alloc] initWithKey:@"CompanyName" ascending:YES selector:@selector(caseInsensitiveCompare:)] ;
[companyListArray sortUsingDescriptors:[NSArray arrayWithObject:lastNameDescriptor]];
[lastNameDescriptor release];
use like this and try
Upvotes: 0