I have a fruit
object in swift with
var title: String?
var desc: String?
variables
I have it in a fruitsArray
which is an NSMutableArray.
I want to sort out these fruit objects alphabetically depending on their title. I need to do this both ascending and descending.
I have tried doing the following:
NSSortDescriptor *sortDescriptor =
[NSSortDescriptor sortDescriptorWithKey:@"title"
ascending:YES
selector:@selector(caseInsensitiveCompare:)];
[fruitsArray sortedArrayUsingDescriptors:@[sortDescriptor]];
But it does not work at all, just heaps of errors.
How do I do this?
Thanks in advance friends.