Skip to content

Instantly share code, notes, and snippets.

@apphands
Last active June 23, 2016 00:53
Show Gist options
  • Save apphands/4e658980319f278bbd17b8a1fa2450b0 to your computer and use it in GitHub Desktop.
Save apphands/4e658980319f278bbd17b8a1fa2450b0 to your computer and use it in GitHub Desktop.
Sort NSDictionary keys in descending order
NSDictionary *dict = @{@"a":@1, @"b":@3, @"z":@24};
NSArray *sortedArray = [dict keysSortedByValueUsingComparator:^NSComparisonResult(id _Nonnull obj1, id _Nonnull obj2) {
return [obj1 integerValue] < [obj2 integerValue];
}];
NSLog(@"dict: %@", sortedArray);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment