Try the following:
NSArray* newArray = [array sortedArrayUsingComparator: ^NSComparisonResult(MyClass *c1, MyClass *c2) { NSDate *d1 = c1.date; NSDate *d2 = c2.date; return [d1 compare:d2]; }];
There is also a way to sort the modified array in place, similar to the one above.
EDIT: I know there are other ways to do this using less code, but I really prefer block counters for all kinds of things, so I find it useful to keep practicing. You can also tweak them to use more custom sorting (ints versus objects) and actually record what happens with NSLog () ...).
source share