Some idiomatic changes suggested by Brandon Rodes.
1) Use key= instead of cmp= for sorting when possible.
2) Use tuples as dictionary keys rather than concatenating strings.
3) Omit parens when destructuring in a for loop.