• 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: Jeff Laing <email@hidden>
  • Date: Wed, 21 Jul 2010 01:05:23 +0000
  • Acceptlanguage: en-US
  • Thread-topic: case-insensitive but case-ordered sort

> 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

I had to solve this for a different system (sadly, I can't share code) and the first problem you face is that you need to be more specific with your rules than what you have.  We sorted A before a, but have the following rules:

	 * "A"   < "a"
	 * "Ab"  > "a"
	 * "Ab"  > "aa"
	 * "Ab"  < "ab"
	 * "Ab"  < "ad"
	 * "Abc" > "ab"

and it turned out that you can't compare one character at a time.  Sometimes you need to look further along the string to decide what your relative orders are.

(Note, our compare also handled numerics inside the string as well. This was all complicated enormously because our users think that "File-1" < "File-2" but "-2" < "-1" ... think about it)

Our approach was to skip over "ambiguous" matches (ie, treat "A"=="a") until you find a difference, or decide that the strings are the same.  If the tails are different, return that difference.  Otherwise return the difference in the *first* ambiguous match you found.

_______________________________________________

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

  • Prev by Date: Missing resize control when NSScrollView.wantsLayer = YES? (bumped)
  • Next by Date: Re: WebView pagination for printing
  • Previous by thread: Re: case-insensitive but case-ordered sort
  • Next by thread: Can't get "pmset" to work
  • Index(es):
    • Date
    • Thread