baste baste - 3 months ago 10x
Objective-C Question

How to sort an array of dates in descending order

I have a NSDictionary that parsed to an array one of the element is date, i tried using

[startimeArray sortUsingSelector:@selector(compare:)];
(starttimeArray) is my date but it only arrange ascending. how can i sort in descending order. thanks


Sort the array by puting NO is ascending parameter:

NSSortDescriptor *descriptor=[[NSSortDescriptor alloc] initWithKey:@"self" ascending:NO];
NSArray *descriptors=[NSArray arrayWithObject: descriptor];
NSArray *reverseOrder=[dateArray sortedArrayUsingDescriptors:descriptors];