Skip to content

Instantly share code, notes, and snippets.

@valexa
Created October 1, 2010 15:03
Show Gist options
  • Save valexa/606325 to your computer and use it in GitHub Desktop.
Save valexa/606325 to your computer and use it in GitHub Desktop.
NSArray *sortedFirstNames = [firstNames sortedArrayUsingFunction:familyNameCompare context:NULL];
NSInteger familyNameCompare(NSString *one, NSString *two, void *context)
{
NSArray *sortedFamilyNames = [[FirstNamesAndFamilyNames allValues] sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
NSString *oneName = [FirstNamesAndFamilyNames objectForKey:one];
NSString *twoName = [FirstNamesAndFamilyNames objectForKey:two];
if ([sortedFamilyNames indexOfObject:oneName] < [sortedFamilyNames indexOfObject:twoName]){
return NSOrderedAscending;
}else if ([sortedFamilyNames indexOfObject:oneName] > [sortedFamilyNames indexOfObject:twoName]){
return NSOrderedDescending;
}else{
return NSOrderedSame;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment