2
我想按字母順序排列數組。在瑞典語字母表中,字母Å是字母表中的倒數第三個字母,因此下面的數組應按A, B, Å
排序,但它會按A, Å, B
排序。什麼可能是這種行爲的原因?localizedCaseInsensitiveCompare似乎不適用於瑞典語字符
NSArray *test = @[@"Å", @"A", @"B"];
NSArray *sortedTest = [test sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)];
// Output is A, Å, B
是localizedCaseInsensitiveCompare:在文檔中?我沒有找到它。 –
@RamyAlZuhouri:[localizedCaseInsensitiveCompare:](https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#//apple_ref/occ/instm/ NSString/localizedCaseInsensitiveCompare :) –