Skip to content

Instantly share code, notes, and snippets.

@agiletalk
Created November 1, 2013 04:55
Show Gist options
  • Save agiletalk/7261108 to your computer and use it in GitHub Desktop.
Save agiletalk/7261108 to your computer and use it in GitHub Desktop.
iOS에서 사용자 로케일 순으로 정렬하기
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"key_name" ascending:YES comparator:^NSComparisonResult(id obj1, id obj2) {
NSStringCompareOptions comparisonOptions = NSCaseInsensitiveSearch | NSNumericSearch | NSWidthInsensitiveSearch | NSForcedOrderingSearch;
NSRange stringRange = NSMakeRange(0, ((NSString *)obj1).length);
return [(NSString *)obj1 compare:(NSString *)obj2 options:comparisonOptions range:stringRange locale:[NSLocale autoupdatingCurrentLocale]];
}];
sortedArray = [[NSMutableArray alloc] initWithArray:[arrayFromSQLite sortedArrayUsingDescriptors:@[sortDescriptor]]];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment