How do operator.itemgetter() and sort() work?
Looks like you’re a little bit confused about all that stuff. operator is a built-in module providing a set of convenient operators. In two words operator.itemgetter(n) constructs a callable that assumes an iterable object (e.g. list, tuple, set) as input, and fetches the n-th element out of it. So, you can’t use key=a[x][1] there, because python has no idea what x is. … Read more