case-insensitive but case-ordered sort
case-insensitive but case-ordered sort
- Subject: case-insensitive but case-ordered sort
- From: Roland King <email@hidden>
- Date: Wed, 21 Jul 2010 01:39:04 +0800
I want to sort some NSStrings in such a way that words group case insensitively, but within that group lowercase comes first, effectively I want the sort order of letters to be
aAbBcCdDeEfF .. etc with everything outside the letter space sorting 'naturally' and coming after the letters (I actually don't care too much about the last bit honestly they can go where they like as long as it's outside the alphabet range).
so
myClass comes before
MyClass which comes before
yourClass which comes before
YourClass
First off is there a defined sort routine in or around NSString which does something like this (I found a kCFCompareForcedOrdering flag in CFString which seems to do something similar, but possibly backwards from what I want). I can restrict the domain to ASCII without any real issues but if there's something which is localized, that would be better.
I thought perhaps that comparing the two strings case insensitively, returning that compare if they are not equal, but if they are equal, comparing them case sensitively and returning the inverse of that (remember I want a to beat A) would do what I want but I've failed to convince myself that actually works.
Is there an NSString or CFString method I should be looking at or am I off to roll my own? _______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden