Update: The list are filled with strings I edited the list to show this
I have 3 different list such as
Section = [(\'1\', \'1.1\', \'1.2\'), (\'1\',
You can do:
from itertools import chain
tuples = zip(map(float, list(chain(*Section))),
list(chain(*Page)),
list(chain(*Title)))
zip(*sorted(tuples, key=lambda x: x[0]))
Out[232]:
[(1.0, 1.0, 1.0, 1.1, 1.2, 1.2, 2.0, 2.2, 3.0, 3.2, 3.5),
('1', '1', '1', '1', '3', '2', '2', '2', '2', '3', '5'),
('General',
'More',
'Another',
'Info',
'Titles',
'List',
'Info',
'Section',
'Here',
'Of',
'Strings')]
Here you first unnest your three list (what list(chain(*L))
does) and pack them in tuples with zip
. Tip "tuples" to see how it looks.
Then on the second line of code you can apply the sorting according to the element of the tuple you want. And you unpack the result.