sorting a dictionary


/ Published in: Python
Save to your folder(s)

Dictionaries cant be sorted, so you need to transform it into a list and sort that one!


Copy this code and paste it in your HTML
  1. You could use:
  2.  
  3. sorted(dictionaryObject.items(), key=lambda x: x[1] )

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.