Reputation: 12184
I am sorting An Array of Strings using a comparator block. The comparison logic of two strings should leave aside case,punctuation marks like apostrophes ,commas and full stops and also white space characters.
UPDATE:
Strip Non-Alphanumeric Characters from an NSString
Just saw this SO post, used this to do a case-Insensitive comparison of strings after removing non alphanumeric characters.
Upvotes: 1
Views: 539
Reputation: 12496
You'll have to make a temporary string that has the characters that you don't like to participate in the comparison removed.
If you have a lot of strings you might want to cache these temporary strings (like in a dictionary with the real string as key and the temp string as data), or implement your own comparision function so you don't have to repeatedly create and discard those temporary strings.
Upvotes: 1