while - (void)sortUsingSelector:(SEL)comparator
method suppose to sorts the array's elements in ascending order, the comparator method should return NSOrderedAscending
if the array is smaller than the argument, NSOrderedDescending
if the array is larger than the argument, and NSOrderedSame
if they are equal.
Since the NSComparisonResult define as:
enum {
NSOrderedAscending = -1,
NSOrderedSame,
NSOrderedDescending
};
typedef NSInteger NSComparisonResult;
All you need is a descendingComparator, something like:
- (NSComparisonResult)compareNameInDesendingOrder:(AddressCard *)aCard {
return -[self.name compare:[aCard name]];
}
- (void)sortInDesendingOrder {
[book sortUsingSelector:@selector(compareNameInDesendingOrder:)];
}
hope it helps.