I have an NSArray of NSNumber objects that I have successfully sorted in ascending order using the following:
[myArray sortedArrayU
There are a few ways:
sortUsingFunction:context:.sortUsingComparator:, which takes a block. (Only available in Mac OS X 10.6 and later and iOS 4.0 and later.)sortUsingDescriptors:, and pass an array of at least one sort descriptor whose ascending property is false.In the first two cases, your comparison should simply return the negation of what the comparator you normally use (e.g., compare:) returned. The last one involves less custom code, so it's what I'd use.