If you wanted to simply get the min and max doubles:
NSNumber* min = [array valueForKeyPath:@"@min.self"];
NSNumber* max = [array valueForKeyPath:@"@max.self"];
If you wanted to simply sort them:
// the array is mutable, so we can sort inline
[array sortUsingSelector:@selector(compare:)];
The NSNumber
class will sort nicely just using compare:
, but if you need to do more complicated sorting, you can use the -sortUsingComparator:
method which takes a block to do the sorting. There are also methods on NSArray
which will return new arrays that are sorted, instead of modifying the current array. See the documentation for NSArray and NSMutableArray for more information.