def CmpToKey(mycmp):
 class K(object, ):
  def __init__(self, obj):
   self.obj = obj
  def __lt__(self, other):
   return (mycmp(self.obj, other.obj) == (-1))
 return K

def CmpToKey ( mycmp ) : class K ( object , ) : def __init__ ( self , obj ) : self . obj = obj def __lt__ ( self , other ) : return ( mycmp ( self . obj , other . obj ) == ( - 1 ) ) return K
convert a cmp= function into a key= function .