Created
July 12, 2010 03:18
-
-
Save tonyarnold/472094 to your computer and use it in GitHub Desktop.
Dr. Tran's Hickory Chicken Sortables
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| NSSortDescriptor *groupSortDescriptor = [[[NSSortDescriptor alloc] initWithKey:@"group" ascending:YES selector:@selector(groupCompare:)] autorelease]; | |
| NSSortDescriptor *orderSortDescriptor = [[[NSSortDescriptor alloc] initWithKey:@"order" ascending:YES] autorelease]; | |
| NSArray *descriptors = [NSArray arrayWithObjects:groupSortDescriptor, orderSortDescriptor, nil]; | |
| NSArray *sortedShortcuts = [allShortcuts sortedArrayUsingDescriptors:descriptors]; | |
| // Re-sort the group name string objects (they've just been jumbled on Leopard - YAY!) | |
| NSSortDescriptor *groupObjectSortDescriptor = [[[NSSortDescriptor alloc] initWithKey:@"self" ascending:YES selector:@selector(groupCompare:)] autorelease]; | |
| NSMutableArray *distinctGroupNames = [sortedShortcuts valueForKeyPath:@"@distinctUnionOfObjects.group"]; | |
| NSArray *sortedDistinctGroupNames = [distinctGroupNames sortedArrayUsingDescriptors:[NSArray arrayWithObject:groupObjectSortDescriptor]]; | |
| for (NSString *groupName in sortedDistinctGroupNames) { | |
| … | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment