• 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: Graham Cox <email@hidden>
  • Date: Thu, 02 Aug 2012 12:52:48 +1000

On 02/08/2012, at 1:53 AM, Alex Zavatone wrote:

> not having sorted dicts (in a straightforward way) is an offense to all that it holy and good.


I disagree. Dictionaries by their nature are not "sorted" because they are random-access containers. Separating the responsibility for sorting into another class (NSMutableArray) is a good example of the correct separation of concerns. Besides, what does "sorted" mean? There's no single definition of sorted, that's why there are many ways to accomplish it, with case sensitive or not, different locales, and so on.

If you really want a sorted dictionary, for your own definition of "sorted", adding the feature via a category is no problem.

> it would seem to make a boatload of sense to be able to grab keys and objects/values from dicts simply by using their index

Maybe you're just using the wrong container for the job. Dictionaries have no index, the very concept does not make sense for a dictionary. THAT IS THEIR POINT! If you want indexing, use an array. If you want some sort of hybrid, composite one in a class of your own device.




--Graham


_______________________________________________

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: -[NSFileHandle readInBackgroundAndNotify] opens the file again
  • Next by Date: Re: Icon Overlay on Mac OSX
  • 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