Skip to content

Instantly share code, notes, and snippets.

@azu
Created February 17, 2014 03:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save azu/9044495 to your computer and use it in GitHub Desktop.
Save azu/9044495 to your computer and use it in GitHub Desktop.
countしてsort
NSDictionary *dictionary = AZ_ASTCount(
@[@"a", @"d", @"d", @"a", @"d", @"c", @"b", @"c"], ^id <NSCopying>(NSString *obj) {
return obj;
});
NSArray *orderedKeys = [dictionary keysSortedByValueUsingComparator:^NSComparisonResult(id obj1, id obj2) {
return [obj1 compare:obj2];
}];
NSLog(@"dictionary = %@", orderedKeys);
/*
dictionary = (
b,
c,
a,
d
)
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment