Quintuplicate

Untitled

Jul 8th, 2021 (edited)
351
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.49 KB | None | 0 0
  1. # Credits to Ctrl-S.
  2. # Given my_dict as a dict, where elements are either ints or lists of ints...
  3.  
  4. # Convert to list of ints:
  5. to_sort = []
  6. for k in my_dict.keys():
  7.      val = my_dict[k]
  8.      if type(val) == int:
  9.          to_sort.append(val)
  10.      else:
  11.          for subval in val:
  12.              to_sort.append(subval)
  13. # Sort resulting list:
  14. # One of these will be sort of right
  15. results = sorted(to_sort)
  16. results = sort(to_sort)
  17. results = to_sort.sort()
  18. results = to_sort.sorted()
Add Comment
Please, Sign In to add comment