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