• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: case-insensitive but case-ordered sort
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: case-insensitive but case-ordered sort


  • Subject: Re: case-insensitive but case-ordered sort
  • From: Deborah Goldsmith <email@hidden>
  • Date: Tue, 20 Jul 2010 17:19:42 -0700

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 (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

_______________________________________________

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

References: 
 >case-insensitive but case-ordered sort (From: Roland King <email@hidden>)
 >Re: case-insensitive but case-ordered sort (From: Keary Suska <email@hidden>)

  • Prev by Date: mach_msg timing out + QuickTime
  • Next by Date: Missing resize control when NSScrollView.wantsLayer = YES? (bumped)
  • Previous by thread: Re: case-insensitive but case-ordered sort
  • Next by thread: RE: case-insensitive but case-ordered sort
  • Index(es):
    • Date
    • Thread