pigar/helpers.py
def cmp_to_key(cmp_func):
    """Convert a cmp=function into a key=function."""
    class K(object):
        def __init__(self, obj, *args):
            self.obj = obj

        def __lt__(self, other):
            return cmp_func(self.obj, other.obj) < 0

        def __gt__(self, other):
            return cmp_func(self.obj, other.obj) > 0

        def __eq__(self, other):
            return cmp_func(self.obj, other.obj) == 0

    return K
Convert a cmp=function into a key=function.
Convert a cmp=function into a key=function.
Convert a cmp = function into a key = function .
def cmp_to_key(cmp_func):
    class K(object):
        def __init__(self, obj, *args):
            self.obj = obj
        def __lt__(self, other):
            return cmp_func(self.obj, other.obj) < 0
        def __gt__(self, other):
            return cmp_func(self.obj, other.obj) > 0
        def __eq__(self, other):
            return cmp_func(self.obj, other.obj) == 0
    return K
def cmp_to_key ( cmp_func ) : class K ( object ) : def __init__ ( self , obj , * args ) : self . obj = obj def __lt__ ( self , other ) : return cmp_func ( self . obj , other . obj ) < 0 def __gt__ ( self , other ) : return cmp_func ( self . obj , other . obj ) > 0 def __eq__ ( self , other ) : return cmp_func ( self . obj , other . obj ) == 0 return K
Convert a cmp=function into a key=function.
Convert a cmp = function into a key = function .
"""Convert a cmp=function into a key=function."""
cmp_func