Comment

Fred

Nice technique! Small nit-pick: "... which is an error we deserve because this won't work for the first part of each tuple." That's not accurate. It doesn't fail because str.lower can't be applied to the first part of the tuple. It fails because it can't be applied to the tuple (the whole thing, which is an object in its own right). The "key" function gets passed every item in the iterable you're sorting, and str.lower can't take tuples. It does *not* get passed the contents inside the tuple one by one.