NB: 1. Standard ordering for most languages is capitals before lowercase. 2. Some languages have lowercase first. 3. -localizedStandardCompare: will take care of this for you.
In general, it’s better to leave decisions like this to the system. Sorts of lists to be shown to end-users should never be case- or diacritic-insensitive, as correct sorting in many languages depends on case- and diacritic-sensitivity. Note that for a localized sort, being case-sensitive does *not* mean you’ll get: ABCDabcd That’s code-point order, which is not at all the same thing. What case-sensitive means for a localized sort is that you’ll get a definite ordering (e.g., capitals before lower-case, all else being equal). The way Unicode sorting works is: 1. First, sort on the value of the letter 2. Then, sort on diacritics 3. Then, sort on case Each succeeding level is only done if the preceding levels compare equal *for the entire string*. See: http://userguide.icu-project.org/collation http://userguide.icu-project.org/collation/concepts Deborah Goldsmith Apple, Inc. On Jul 20, 2010, at 1:48 PM, Keary Suska wrote: > On Jul 20, 2010, at 11:39 AM, Roland King wrote: > >> 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. > > This approach will not provide overall lower-before-capital sorting, so I > expect it won't work. Consider the following: > > aClass > AAClass > > Will sort, using the method you describe, to > > AAClass > aClass > > Because A comes before C and they are unequal (so a is never compared to A). > Using a custom selector/function is probably the only way to go, and I can't > think of any built-in method that will give the collation results you are > looking for. I don't think you can escape a character-by-character comparison. > > HTH, > > Keary Suska > Esoteritech, Inc. > "Demystifying technology for your home or business" > > _______________________________________________ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > 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: > http://lists.apple.com/mailman/options/cocoa-dev/goldsmit%40apple.com > > This email sent to golds...@apple.com _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com