I have a dictionary, say
{'name4': 380, 'name2': 349, 'name3': 290, 'name1': 294}
I have sorted the dictionary based on the values using the sorted
method and the result is a list of tuples
[('name3', 290), ('name1', 294), ('name2', 349), ('name4', 380)]
But, when I try to convert this list of tuples back to dictionary, it's back again to the old structure:
{'name4': 380, 'name2': 349, 'name3': 290, 'name1': 294}
I want the sorted list to be made into dictionary as it is. I have used dict()
and manually used for loop to assign the values. But it's again leading to the same result.
Could anyone help me on this?