Created
November 1, 2013 04:55
-
-
Save agiletalk/7261108 to your computer and use it in GitHub Desktop.
iOS에서 사용자 로케일 순으로 정렬하기
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 *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