tags:

views:

42

answers:

2

i have NSArray which have dictionary object and in dictionary for "ORDER " key i want to sort array. any suggestion?

+3  A: 

Read the Sorting with Sort Descriptors section of Apple's Collections Programming Topics.

The example in this section covers sorting an array of dictionary objects by their keys.

Alex Reynolds
A: 

Here is an example. Imagines you have an array of dictionnaries. Ecah dictionnary have 2 keys "name" & "dateOfBirth". You can sort your array by "name" like this :

//
// Sort array by name
//
NSSortDescriptor *Sorter = [[NSSortDescriptor alloc] initWithKey:@"name" ascending:YES];
[myArray sortUsingDescriptors:[NSArray arrayWithObject:Sorter]];
[Sorter release];

Note that myArray is a NSMutableArray.

Niko