Created
January 19, 2018 03:17
-
-
Save Koze/cce2144c2b2ecd808f9af90262aa37dd to your computer and use it in GitHub Desktop.
String sort similar to iOS.
This file contains 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
- (void)sortTest | |
{ | |
NSArray<NSString *> *array = @[@"英語", @"中国語", @"韓国語", @"ロシア語", @"ルーマニア語"]; | |
for (NSString *string in [array sortedArrayUsingSelector:@selector(compare:)]) { | |
NSLog(@"%@", string); | |
} | |
NSLog(@"\n"); | |
// ルーマニア語 | |
// ロシア語 | |
// 中国語 | |
// 英語 | |
// 韓国語 | |
for (NSString *string in [array sortedArrayUsingSelector:@selector(localizedCompare:)]) { | |
NSLog(@"%@", string); | |
} | |
NSLog(@"\n"); | |
// ルーマニア語 | |
// ロシア語 | |
// 英語 | |
// 韓国語 | |
// 中国語 | |
// similar to iOS | |
for (NSString *string in [array sortedArrayUsingSelector:@selector(localizedStandardCompare:)]) { | |
NSLog(@"%@", string); | |
} | |
// ルーマニア語 | |
// ロシア語 | |
// 英語 | |
// 韓国語 | |
// 中国語 | |
// similar to iOS | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment