I want to sort the Dictionary value following is my dictionary response that have four key value pair like- “artist_id”, “artworks_count”,”first_name”,”last_name”. I want to sort it according to “first_name” how to do. please help me.
2012-03-02 16:10:41.299 Paddle8[4928:207] The currentArtistNameDict is-- >{
"artist_id" = 370;
"artworks_count" = 1;
"first_name" = Gerri;
"last_name" = Davis;
}
2012-03-02 16:10:41.300 Paddle8[4928:207] The currentArtistNameDict is-- >{
"artist_id" = 369;
"artworks_count" = 1;
"first_name" = Stephen;
"last_name" = Cimini;
}
2012-03-02 16:10:41.302 Paddle8[4928:207] The currentArtistNameDict is-- >{
"artist_id" = 367;
"artworks_count" = 1;
"first_name" = Melinda;
"last_name" = Buie;
}
2012-03-02 16:10:41.305 Paddle8[4928:207] The currentArtistNameDict is-- >{
"artist_id" = 358;
"artworks_count" = 7;
"first_name" = Kcho;
"last_name" = "<null>";
}
Any help is highly Appreciated..
NSDictionary objects are by definition unsorted, so you’d be best off iterating through your dictionary and putting the items into an NSMutableArray, and then using the sortUsingDescriptors method to sort the array.
Here’s an example that might help:
(taken from http://www.iphonedevsdk.com/forum/iphone-sdk-development/6146-sort-array-dictionary-objects.html)