Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. 45 67 Row Fine
  2. 25 22 Abe Real
  3. 58 54 Abe Noon
  4.  
  5. 58 54 Abe Noon
  6. 25 22 Abe Real
  7. 45 67 Row Fine
  8.  
  9. iterable_of_rows = zip(*my_list_of_columns)
  10.  
  11. import operator
  12. sorted_list_of_rows = sorted(zip(*my_list_of_columns), key = operator.itemgetter(2,3))
  13. list_of_columns = list(zip(*sorted_list_of_rows))
  14.  
  15. >>> my_list_of_columns = [[45,25,48],[67,22,54],["Row","Abe","Abe"],["Fine","Real","Noon"]]
  16. >>> import operator
  17. >>> sorted_list_of_rows = sorted(zip(*my_list_of_columns), key = operator.itemgetter(2,3))
  18. >>> list_of_columns = list(zip(*sorted_list_of_rows))
  19. >>> list_of_columns
  20. [(48, 25, 45), (54, 22, 67), ('Abe', 'Abe', 'Row'), ('Noon', 'Real', 'Fine')]
  21.  
  22. >>> print(data)
  23. [[45, 25, 58], [67, 22, 54], ['Row', 'Abe', 'Abe'], ['Fine', 'Real', 'Noon']]
  24.  
  25. >>> print(sorted(zip(*data), key=lambda x: (x[2], x[3])))
  26. [(58, 54, 'Abe', 'Noon'), (25, 22, 'Abe', 'Real'), (45, 67, 'Row', 'Fine')]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement