I have an NSMutableDictionary with integer values, and I\'d like to get an array of the keys, sorted ascending by their respective values. For example, with thi
NSMutableDictionary
Here's a solution:
NSDictionary *dictionary; // initialize dictionary NSArray *sorted = [[dictionary allKeys] sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) { return [[dictionary objectForKey:obj1] compare:[dictionary objectForKey:obj2]]; }];