3 ms·
def length_and_alphabetical(string): """Return sort key: length first, then case-normalized string.""" return (len(string), string.casefold())
by wrs 8y ago
def length_and_alphabetical(string):
"""Return sort key: length first, then case-normalized string."""
return (len(string), string.casefold())
You just said the same thing three different ways. Not having to do that is exactly what lambda expressions are for.