I\'m trying to sort an array alphabetically. In the swedish alphabet the letter Å is third last letter in the alphabet so the below array should be sorted like A, B, Å
Perhaps the current locale is not the Swedish locale?
It works as expected if you explicitly use a Swedish locale for sorting the strings:
NSArray *test = @[@"Å", @"A", @"B"];
NSLocale *swedish = [[NSLocale alloc] initWithLocaleIdentifier:@"sv"];
NSArray *sortedTest = [test sortedArrayWithOptions:0
usingComparator:^(NSString *v1, NSString *v2) {
return [v1 compare:v2 options:NSCaseInsensitiveSearch
range:NSMakeRange(0, [v1 length])
locale:swedish];
}];
// Output: A, B, Å