I have an NSArray of NSNumber objects that I have successfully sorted in ascending order using the following:
[myArray sortedArrayU
Another way, imo, is also nice: write another reverseCompare with category:
@implementation NSNumber (Utility)
- (NSComparisonResult)reverseCompare:(NSNumber *)aNumber {
return [aNumber compare:self];
}
The good thing is that you can reuse everywhere and don't have to write the loop with reverse iterate. The bad thing is that you have to write more code:)