views:

148

answers:

1

Hi

I have an NSMutableArray of objects, let's say 'Person' Objects. I want to sort the NSMutable Array by person.savings i.e if suppose person having savings 1000,1050,500,1200,2000,1050 i want the Array in the ascending order.

Thank You.

A: 
NSSortDescriptor *myDescriptor = [[NSSortDescriptor alloc] initWithKey:@"savings" ascending:YES];
[myArray sortUsingDescriptors:[NSArray arrayWithObject:myDescriptor]];
mjdth
Hi Thanks for the reply, We are getting the list from database here the savings object is not constant for the corresponding numeric value. It varies for every numeric value
kiri
How are you saving the values to different variables? You might need to just making a sorting function then that checks if the class has a savings variable / whatever else you'd use and go from there.Are you sorting several types of classes?
mjdth