Link to home
Start Free TrialLog in
Avatar of ugeb
ugebFlag for United States of America

asked on

Python sort list of tuples, skipping column

I have a list of tuples of the form (A,B,C) where A, B, and C are all strings.

If, for example, lst = [ ('This','is','it') , ('This','and','that') ], the sorted order lst.sort() would give:
('This','is','it')
('This','and','that')

The first comparison item 'This' is the same in both tuples, so the next comparison item is the third value C, and 'it' comes before 'that' despite the fact that the second value 'and' comes before 'is'.

How do I sort a list of tuples like this?
ASKER CERTIFIED SOLUTION
Avatar of JesterToo
JesterToo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ugeb

ASKER

Great, thank you.