def key_to_cmp(key):
 def key_cmp(a, b):
  return cmp(key(a), key(b))
 return key_cmp

def key_to_cmp ( key ) : def key_cmp ( a , b ) : return cmp ( key ( a ) , key ( b ) ) return key_cmp
comparator function based on "key" function .