#NEWLINE# @ property #NEWLINE# def key( self ) : #NEWLINE# #INDENT# accessors = [ ] #NEWLINE# reversing = [ ] #NEWLINE# for order_by in self : #NEWLINE# #INDENT# accessors . append ( Accessor ( order_by . bare ) ) #NEWLINE# reversing . append ( order_by . is_descending ) #NEWLINE# #UNINDENT# @ total_ordering #NEWLINE# class Comparator ( object ) : #NEWLINE# #INDENT# def __init__( self , obj ) : #NEWLINE# #INDENT# self . obj = obj #NEWLINE# #UNINDENT# def __eq__( self , other ) : #NEWLINE# #INDENT# for accessor in accessors : #NEWLINE# #INDENT# a = accessor . resolve ( self . obj , quiet = True ) #NEWLINE# b = accessor . resolve ( other . obj , quiet = True ) #NEWLINE# if ( not ( a == b ) ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# #UNINDENT# return True #NEWLINE# #UNINDENT# def __lt__( self , other ) : #NEWLINE# #INDENT# for ( accessor , reverse ) in six . moves . zip ( accessors , reversing ) : #NEWLINE# #INDENT# a = accessor . resolve ( self . obj , quiet = True ) #NEWLINE# b = accessor . resolve ( other . obj , quiet = True ) #NEWLINE# if ( a == b ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# if reverse : #NEWLINE# #INDENT# ( a , b ) = ( b , a ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# return ( a < b ) #NEWLINE# #UNINDENT# except TypeError : #NEWLINE# #INDENT# if ( bool ( a ) is not bool ( b ) ) : #NEWLINE# #INDENT# return ( bool ( a ) < bool ( b ) ) #NEWLINE# #UNINDENT# a_type = type ( a ) #NEWLINE# b_type = type ( b ) #NEWLINE# return ( ( repr ( a_type ) , id ( a_type ) ) < ( repr ( b_type ) , id ( b_type ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# return False #NEWLINE# #UNINDENT# #UNINDENT# return Comparator