Re: sorting an array of dictionaries
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