I have an NSArray which contains custom objects like this:
NSArray *array = {
students,students
}
And student object in turns store values like :
student.name,
student.class,
student.admissionDate
student.school ..etc
Now I want an NSArray which contains all the student's detail sorted in based on their admissionDate.
I tried using NSSortDecriptor but it doesn't helped me.
EDIT
After some hard work I have successfully formed a NSMutable array of NSDictionary which Looks like:
for(Student *arr in array)
{
NSMutableDictionary *dict;
dict = [[NSMutableDictionary alloc]init];
[dict setObject:arr.stuName forKey:@"name"];
[dict setObject:arr.stuAdate forKey:@"date"];
[dict setObject:arr.stuClass forKey:@"class"];
[expenseArray addObject:dict];
}
Printing description of expenseArray:
<__NSArrayM 0x7fe703833f70>(
{
name = uuu;
Adate = "2015-10-10 10:56:03 +0000";
class = 1st;
},
{
name = abc;
Adate = "2015-10-07 11:10:00 +0000";
class = 3rd;
},
{
name = btw;
Adate = "2015-10-10 11:13:47 +0000";
class = 4th;
}
)
Now how can i sort based on date
admissionDate? aNSDateaNSString?