Instance Method

keysSortedByValueUsingSelector:

Returns an array of the dictionary’s keys, in the order they would be in if the dictionary were sorted by its values.

Declaration

- (NSArray<KeyType> *)keysSortedByValueUsingSelector:(SEL)comparator;

Parameters

comparator

A selector that specifies the method to use to compare the values in the dictionary.

The comparator method should return NSOrderedAscending if the dictionary value is smaller than the argument, NSOrderedDescending if the dictionary value is larger than the argument, and NSOrderedSame if they are equal.

Return Value

An array of the dictionary’s keys, in the order they would be in if the dictionary were sorted by its values.

Discussion

Pairs of dictionary values are compared using the comparison method specified by comparator; the comparator message is sent to one of the values and has as its single argument the other value from the dictionary.

See Also

Sorting Dictionaries

- keysSortedByValueUsingComparator:

Returns an array of the dictionary’s keys, in the order they would be in if the dictionary were sorted by its values using a given comparator block.

- keysSortedByValueWithOptions:usingComparator:

Returns an array of the dictionary’s keys, in the order they would be in if the dictionary were sorted by its values using a given comparator block and a specified set of options.