KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Let us consider a dictionary: sample_dict={1:'r099',2:'g444',3:'t555',4:'f444',5:'h666'} I want to re-order this dictionary in an order specified by a list containing the order of the dictionary keys that I desire. Let us say the desired order list is: desired_order_list=[5,2,4,3,1] So, I want my dictionary to appear like this: {5:'h666',2:'g444',4:'f444',3:'t555',1:'r099'} If I can get a list of values that is fine too. Meaning, the result can be this: ['h666','g444','f444','t555','r099'] How do I achieve this in the least complex way possible?
Tags (comma-separated)
Save Edits
Cancel