I have a question about sorting NSMutableArray. I can use sortedArrayUsingDescriptors: method to sort an array with objects.
For example I have an NSMutableArray of places where I have an attribute frequency (int value) and I want to sort descending on frequency but I don't know how to use it correctly.
What do I put as a key in initWithKey?
My object place contains:
NSString * name;
NSString * address;
NSString * frequency;
NSString * type;
NSMutableArray * places;
... populate array with objects ...
NSSortDescriptor * sortByFrequency =
[[[NSSortDescriptor alloc] initWithKey:@"????????" ascending:NO] autorelease];
NSArray * descriptors = [NSArray arrayWithObject:sortByFrequency];
NSArray * sorted = [x sortedArrayUsingDescriptors:descriptors];