I have an NSMutableArray that contains dates in a string format. Here I need to sort that array in ascending order of dates. I used:
NSSortDescriptor *descriptor=[[NSSortDescriptor alloc] initWithKey:@"self" ascending:YES];
NSArray *descriptors=[NSArray arrayWithObject: descriptor];
NSArray *reverseOrder=[dateArray sortedArrayUsingDescriptors:descriptors];
But it only sort the dates in terms of ascending order of day and month. Year is not considered.
For example, Array contains
03/09/2017, 03/06/2016, 01/06/2016,01/04/2016 and 03/01/2017.
After using the above lines of code, Array contains like,
01/04/2018, 01/06/2016, 03/01/2017, 03/06/2016, 03/09/2016