I have and array of custom objects of Person Class
Person : NSObject{
NSString *firstName;
NSString *lastName;
NSString *age;
}
NSMutableArray
I have created a small library called Linq-to-ObjectiveC which provides a number of methods which make is easier to query arrays. In order to perform the group operation you require you can simply do the following:
NSDictionary* groupedByName = [personsArray groupBy:^id(id person) {
return [person firstName];
}];
This would return a dictionary where the keys are the distinct first names, and each value is an array of 'person' objects that have the given first name.