I have a NSMutableArray consisting out of NSStrings. When I need to sort it, I use [array sortUsingSelector:@selector(caseInsensitiveCompare:)] which works perfect.
But sometimes I need to sort the array by substrings of NSStrings. The substring is defined in this case as part of NSString following some marker. The thing is complicated further by the fact that marker can be positioned differently in every string.
Obviously I can break NSString into 2 objects and do sorting on them but it will require significant changes.
Is there a way to do the sorting using selector similar to what I have described above?
I think if not, then I might sort by creating a sorted copy of an array (instead of using selector to do it in place), then releasing the original.
You can perform any arbitrarily complex sorting inline with NSMutableArray’s sortWithOptions:usingComparator: