I have the following NSArray which contains a dictionary at each index , here is the content, just providing first 3 records-
[
{
"postDate": "4/11/2011 2:03:33 PM",
"imageLink": "",
"eventLink": "www.google.com"
},
{
"postDate": "6/16/2011 1:42:45 PM",
"imageLink": "",
"eventLink": "www.google.com"
},
{
"postDate": "9/21/2011 10:22:34 AM",
"imageLink": "",
"eventLink": "www.google.com"
}
]
NOTE:- postDate
is just a NSString it is not coming in NSDate type, but I have to perform sort on basis of this key.
My task is to sort the array as per the "postDate" key , means the whole array will be sorted in order by date (ascending/descending).
I have used the following code, but didn't help as arr
is storing the all the data from arrEventsData
but sorting is not happening:-
NSSortDescriptor *descriptor = [[NSSortDescriptor alloc] initWithKey:@"postDate" ascending:YES];
NSMutableArray *arr = [[arrEventsData sortedArrayUsingDescriptors:[NSArray arrayWithObjects:descriptor,nil]]mutableCopy];
Any idea or solution will help.
Thanks