• 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
case-insensitive but case-ordered sort
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • RE: case-insensitive but case-ordered sort
      • From: Jeff Laing <email@hidden>
    • Re: case-insensitive but case-ordered sort
      • From: Keary Suska <email@hidden>
    • Re: case-insensitive but case-ordered sort
      • From: Charlie Dickman <email@hidden>
    • Re: case-insensitive but case-ordered sort
      • From: Wim Lewis <email@hidden>
  • Prev by Date: Re: Initializing unichar variable with a human readable letter
  • Next by Date: Re: case-insensitive but case-ordered sort
  • Previous by thread: Re: WebView pagination for printing
  • Next by thread: Re: case-insensitive but case-ordered sort
  • Index(es):
    • Date
    • Thread