I have an array of dictionaries. Within each dictionary, there is a a key dateOfInfo
(an NSDate
) and several other things. I want to sort the array
You can sort using NSSortDescription
, e.g.
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey: @"dateOfInfo" ascending: NO];
NSArray *sortedArray = [array sortedArrayUsingDescriptors:[NSArray arrayWithObject:sortDescriptor]];
[sortDescriptor release];
You can also use the method
- (NSArray *)sortedArrayUsingFunction:(NSInteger (*)(id, id, void *))comparator context:(void *)context