In my project, I'm getting some data from an APi and I retreive the data into a NSMutableArray by parsing the JSON. It has a key called "StartDate" which is of the format : " mm/dd/yyyy hh:mm:ss "
as shown below
StartDate: "5/18/2013 12:00:00 AM"
I'm saving these data to a resultArray .There are also 4 more keys for an object as my JSON is of the form
{
EventId: "xxxx",
Title: "xxx",
Location: "xxxx",
StartDate: "5/18/2013 12:00:00 AM",
Link: null
}
there are multiple such objects here. All that I need to do is to sort the contents of the resultArray based on date(either ascending or descending),
I use the following code
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"StartDate" ascending:TRUE];
[resultArray sortUsingDescriptors:[NSArray arrayWithObject:sortDescriptor]];
But I;m getting a shuffled result, the sorting is not correct throughout, can anyone tel me where I had gone wrong .
Thanks