Use cmp_to_key from functools if possible