1 min read

Can you help me to sort dict in the given order:

d = {1:5,2:6,3:1,4:3,5:23}

now sorted dictionary should be sorted by values such as given below:

d = { 3:1,4:3,1:5,2:6,5:23}

I want to sort the list according to their value retaining its key value.

How can I do this in Python?

Vishal Sharma Answered question October 2, 2019