Possible Duplicate:
How to sort an NSMutableArray with custom objects in it?
Having trouble with something basic (I think).
I have an NSMutable array that I populate with "workout" objects. The "startDate" method returns an NSDate - and I'd like to sort the array off this.
The NSSortDescriptor *sortByDate line terminates due to an uncaught exception. What's wrong here?
NSMutableArray *workouts;
workouts = [[[Workout findByCriteria:@"where state = %@ order by pk desc",
[NSNumber numberWithInt:WorkoutStateComplete]] mutableCopy] autorelease];
NSSortDescriptor *sortByDate = [NSSortDescriptor
sortDescriptorWithKey:@"startDate" ascending:NO];
[workouts sortUsingDescriptors:[NSArray arrayWithObject:sortByDate]];