Re: Sorting NSArray -- advice on how to accomplish a "simple" alpha ordering?
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