• 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 an array of dictionaries
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sorting an array of dictionaries


  • Subject: Re: sorting an array of dictionaries
  • From: Nicko van Someren <email@hidden>
  • Date: Mon, 1 May 2006 12:39:57 +0100

On 1 May 2006, at 11:04, Yorh wrote:
I have a nsmutablearray containing some nsmutabledictionary.
Every dictionary contains 3 values with 3 keys.

NSMutableDictionary:

name: andrew
surname: smith
dateofBirth: 125649479

I need to sort my array based on every name in the dictionary ascending...
How can I do?
I checked the sortedArrayUsingSelector method.... is the rigth one?

Take a look at the NSSortDescriptor class. You should be able to do what you want with:
NSSortDescriptot *d = [[[NSSortDescriptor alloc] initWithKey: @"name" ascending: YES] autorelease];
NSArray *sorted = [myArray sortedArrayUsingDescriptors: [NSArray arrayWithObject: d]];


Cheers,
	Nicko

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: sorting an array of dictionaries
      • From: Andy Lee <email@hidden>
References: 
 >sorting an array of dictionaries (From: Yorh <email@hidden>)

  • Prev by Date: Re: NSString into *arguments[]
  • Next by Date: How to put a icon in the tray?
  • Previous by thread: sorting an array of dictionaries
  • Next by thread: Re: sorting an array of dictionaries
  • Index(es):
    • Date
    • Thread