Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # sort_list_of tuples.py
- list1 = ["what", "I'm", "sorting", "by"]
- list2 = ["something", "else", "to", "sort"]
- pairs = map(None, list1, list2)
- print pairs
- # [('what', 'something'), ("I'm", 'else'), ('sorting', 'to'), ('by', 'sort')]
- pairs.sort()
- print pairs
- # [("I'm", 'else'), ('by', 'sort'), ('sorting', 'to'), ('what', 'something')]
- result = pairs[:]
- for i in xrange(len(result)): result[i] = result[i][1]
- print result
- # ['else', 'sort', 'to', 'something']
- # Note that "I'm" sorts before "by" because uppercase "I" comes before lowercase "b" in the ascii order.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement