iPhone - NSDictionary sorting based on values [duplicate]
Possible Duplicate:
NSDictionary keys sorted by value numerically?
I'm maintaining the scores of my game in a dictionary. Key will be the name of the user and value will be the score. When displaying the scores in table view, I want to sort the dictionary depending on values so that first item will be top score and last item will be least score. How can this be done?
try this one
NSSortDescriptor *descriptor =
[[NSSortDescriptor alloc] initWithKey:@"Score" ascending:YES];
[items sortUsingDescriptors:[NSArray arrayWithObjects:descriptor,nil]];
[descriptor release];
精彩评论