Sort lists in place
Remove code duplication
Don't construct empty lists in tests
Use operator.itemgetter instead of a lambda when possible