What are you creating this array for? Is it a temporary thing that only exists in memory and it used, say, to present a sort list of items to the user? Or are you using it for something more persistent? Or something that’s internal, so not being displayed to the user.
After sorting, the elements are divided into sections and then displayed to the user. The section membership is unstable now which causes the UI framework to throw.
I think I found a workaround for now in this category on NSString:
- (NSComparisonResult)fb24975737LocalizedCaseInsensitiveCompare:(NSString *)other {
NSLocale *locale = NSLocale.currentLocale;
// Fold each entire string first, then collate without case-insensitive options.
NSString *left = [self stringByFoldingWithOptions:NSCaseInsensitiveSearch locale:locale];
NSString *right = [other stringByFoldingWithOptions:NSCaseInsensitiveSearch locale:locale];
return [left compare:right options:0 range:NSMakeRange(0, left.length) locale:locale];
}
With this code I cannot reproduce the inconsistencies anymore. Looks like Foundation's combined case-insensitive comparison is trying to outsmart itself.