I trying to sort some data to use sortedArrayUsingDescriptors: method in an NSArray class.
That method must need to indicate standard comparator, but I want to indicate custom comparator what I make.
Is possible?
Here is part of my sorting code:
NSSortDescriptor *firstDescriptor =
[[[NSSortDescriptor alloc]
initWithKey:FIRSTNAME
ascending:YES
selector:@selector(CustomCompare:)] autorelease];
CustomCompare: <= want to make custom comparator.
Why not use the
sortedArrayUsingComparator:and implement your comparator to be case-insensitive? Something like this:update
For more complex classes, multiple comparison fields may also be used: