Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 45 67 Row Fine
- 25 22 Abe Real
- 58 54 Abe Noon
- 58 54 Abe Noon
- 25 22 Abe Real
- 45 67 Row Fine
- iterable_of_rows = zip(*my_list_of_columns)
- import operator
- sorted_list_of_rows = sorted(zip(*my_list_of_columns), key = operator.itemgetter(2,3))
- list_of_columns = list(zip(*sorted_list_of_rows))
- >>> my_list_of_columns = [[45,25,48],[67,22,54],["Row","Abe","Abe"],["Fine","Real","Noon"]]
- >>> import operator
- >>> sorted_list_of_rows = sorted(zip(*my_list_of_columns), key = operator.itemgetter(2,3))
- >>> list_of_columns = list(zip(*sorted_list_of_rows))
- >>> list_of_columns
- [(48, 25, 45), (54, 22, 67), ('Abe', 'Abe', 'Row'), ('Noon', 'Real', 'Fine')]
- >>> print(data)
- [[45, 25, 58], [67, 22, 54], ['Row', 'Abe', 'Abe'], ['Fine', 'Real', 'Noon']]
- >>> print(sorted(zip(*data), key=lambda x: (x[2], x[3])))
- [(58, 54, 'Abe', 'Noon'), (25, 22, 'Abe', 'Real'), (45, 67, 'Row', 'Fine')]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement