(adsbygoogle = window.adsbygoogle || []).push({}); 1. The problem statement, all variables and given/known data

Hi there,

I need to sort a Python dictionary based on its values which are ints, then return the ordered list as the keys.

I am thinking to make the inverse of the dictionary, take values and sort, then map back with the inverse dictionary.

The problem is that when there are identical values, the inverse dictionary will not store the same value twice as the same key.. so a combination is lost.

I tried to work around it by adding one to the value if the value is repeated, which should not change the sorting.. but am having trouble writing the code.

Any help?

2. Relevant equations

3. The attempt at a solution

**Physics Forums | Science Articles, Homework Help, Discussion**

Dismiss Notice

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Homework Help: Need help with sorting a Python dictionary.

Can you offer guidance or do you also need help?

Draft saved
Draft deleted

**Physics Forums | Science Articles, Homework Help, Discussion**