I have a NSDictionary with NSString
as keys and NSNumber
as values such as the following
NSDictionary *dictionary = @{@"Apple" : [NSNumber numberWithInt: 6],
@"Banana" : [NSNumber numberWithInt: 1],
@"Peach" : [NSNumber numberWithInt: 14],
@"Lychee" : [NSNumber numberWithInt: 1]};
Here, I would like to find the lowest key and value, which in this example would be tie between Lychee : 1
and Banana: 1
. Ordinarlly for a smaller dictionary, I would just sort through all the values as suggested by this answer and retrieve the first (or the tied) object in the array based on the ranking. However, I was wondering if there is a way to do it if the NSDictionary
is very large, where I could just pluck the lowest key-value pairs?
Thanks!