• 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: Sorting NSArray -- advice on how to accomplish a "simple" alpha ordering?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sorting NSArray -- advice on how to accomplish a "simple" alpha ordering?


  • Subject: Re: Sorting NSArray -- advice on how to accomplish a "simple" alpha ordering?
  • From: Andy Lee <email@hidden>
  • Date: Wed, 01 Aug 2012 12:23:28 -0400

On Aug 1, 2012, at 12:08 PM, Alex Zavatone <email@hidden> wrote:
>> If your comparison is only going to be a single method call with a single parameter like this, then probably a bit simpler to use:
>>
>> 	[sortkeys sortUsingSelector:@selector(compare:)];
>
> What's the reason for not using caseInsensitivecompare?

I'm guessing just an oversight.

Also, you can save a line of code with

    NSArray *sortedkeys = [[countries allKeys] sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];

If you need to do anything more than simple alphabetical sort it gets more verbose, but for sorting country names this should suffice.

I suspect this is one of those things for which lots of people have their own category methods on NSArray and/or NSString.

--Andy

_______________________________________________

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: 
 >Re: Sorting NSArray -- advice on how to accomplish a "simple" alpha ordering? (From: Erik Stainsby <email@hidden>)
 >Re: Sorting NSArray -- advice on how to accomplish a "simple" alpha ordering? (From: Michael Babin <email@hidden>)
 >Re: Sorting NSArray -- advice on how to accomplish a "simple" alpha ordering? (From: Alex Zavatone <email@hidden>)

  • Prev by Date: Re: Sorting NSArray -- advice on how to accomplish a "simple" alpha ordering?
  • Next by Date: Re: -[NSFileHandle readInBackgroundAndNotify] opens the file again
  • Previous by thread: Re: Sorting NSArray -- advice on how to accomplish a "simple" alpha ordering?
  • Next by thread: Re: Sorting NSArray -- advice on how to accomplish a "simple" alpha ordering?
  • Index(es):
    • Date
    • Thread