Advertisement
here2share

# sort_by_dict_value_as_kv_list.py

Nov 19th, 2019
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.15 KB | None | 0 0
  1. # sort_by_dict_value_as_kv_list.py
  2.  
  3. x = {'a': 2, 'b': 0, 'c': 3, 'd': 1, 'e': 4}
  4. sorted_x = sorted(x.items(), key=lambda kv: kv[1])
  5. print sorted_x
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement