Skip to content

Instantly share code, notes, and snippets.

@tonyarnold
Created July 12, 2010 03:18
Show Gist options
  • Select an option

  • Save tonyarnold/472094 to your computer and use it in GitHub Desktop.

Select an option

Save tonyarnold/472094 to your computer and use it in GitHub Desktop.
Dr. Tran's Hickory Chicken Sortables
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