I would like to rank the values in a dictionary.
For instance, I have this dictionary: {"A": 10, "B: 3, "C": 8, "D": 3, "E": 2}
The result should look like: {"E": 1, "B": 2, "D": 2, "C": 4, "A": 5}
Please note that D
is ranked as fourth because B
and D
are tied at position two. Hence, there is no position three.
Similar solutions have already been given in other threads, however they did not take into account ex-aequo positions in the traditional way: Adding a rank to a dict in python and Python Ranking Dictionary Return Rank