Do I understand you correctly? Do you want to sort your array by the person's age?
Sorting can be rather easy by using the -sortedArrayUsingComparator:
method of NSArray. Let's say a person has a property called age which is of type NSInteger. We could sort the array like this:
// lets assume _persons_ is an array of Person objects ...
NSArray *sortedPersons = [persons sortedArrayUsingComparator: ^(Person *p1, Person *p2) {
if (p1.age > p2.age) {
return NSOrderedDescending;
}
if (p1.age < p2.age) {
return NSOrderedAscending;
}
return NSOrderedSame;
}];
Of course you could do any kind of comparison in the comparator. E.g. you could compare dates, strings, etc... The NSComparisonResult you return will move items inside the array to the correct position.
EDIT
The following might work in your particular situation:
NSArray *sortedPersons = [persons sortedArrayUsingComparator: ^(Person *p1, Person *p2) {
NSDate *date1 = [p1.birthday asDate];
NSDate *date2 = [p2.birthday asDate];
return [date1 compare:date2];
}];