987. Vertical Order Traversal of a Binary Tree - notruilin/LeetCode GitHub Wiki

Sort a list by multiple attributes

new = sorted(mapping[i], key = lambda x:(x[1], x[0]))

A General example:

s = sorted(s, key = lambda x: (x[1], x[2]))

s = [('KKK',1,2),('LLL',2,3)]

Sort by s[i][1], if s[i][1] are equal, sorted by s[i][2]

lambda x: (x[1], x[2]) x represents s[i]