So I have a person mutablearray where each object contains 3 NSString properties: firstName, lastName and age. I'd like to know how to sort these objects so it's arranged alphabetically by lastName so that I can display that in a table view (and make edits to it later by clicking on the name). Everything else is set up fine, just not the way the names are displayed in the table.
I've tried using
[self.person sortedArrayUsingSelector@selector(caseInsensitiveCompare:)];
but this returns the error: unrecognized selector sent to instance.
All help is appreciated :)
Solved it by using:
NSSortDescriptor *sort = [NSSortDescriptor sortDescriptorWithKey:@"lastName" ascending:YES];
[self.person sortUsingDescriptors:[NSArray arrayWithObject:sort]];
Thanks all for the input :)