Rename key_comparator to key to be consisted with Python's sorted(key=lambda: ...) (also, the function is not technically comparing two items, it's simply extracting the keys that will be compared)
Add explanation and/or an example to the doc string.
Looks good, here's my feedback:
key_comparator
tokey
to be consisted with Python'ssorted(key=lambda: ...)
(also, the function is not technically comparing two items, it's simply extracting the keys that will be compared)