Best way to sort an NSArray of NSDictionary’s in iPhone

Use NSSortDescriptor like this..

NSSortDescriptor *descriptor = [[NSSortDescriptor alloc] 
 initWithKey:@"interest"  ascending:YES]; 
[stories sortUsingDescriptors:
[NSArray arrayWithObjects:descriptor,nil]]; 
recent = [stories copy];
 

Stories is the array you want to sort .recent is another mutable array which has sorted dictionary values.change the “interest” with the key value on which you have to sort.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>