Use cmp_to_key from functools