#NEWLINE# def sort( self , by_headword = True , by_definition = False , reverse = False , ignore_case = False ) : #NEWLINE# #INDENT# if ( ( not by_headword ) and ( not by_definition ) ) : #NEWLINE# #INDENT# self . entries_index_sorted = range ( len ( self . entries ) ) #NEWLINE# return #NEWLINE# #UNINDENT# tmp = [ ] #NEWLINE# i = 0 #NEWLINE# for entry in self . entries : #NEWLINE# #INDENT# first = ( entry . headword if by_headword else '' ) #NEWLINE# if ignore_case : #NEWLINE# #INDENT# first = first . lower ( ) #NEWLINE# #UNINDENT# second = ( entry . definition if by_definition else '' ) #NEWLINE# if ignore_case : #NEWLINE# #INDENT# second = second . lower ( ) #NEWLINE# #UNINDENT# tmp . append ( [ first , second , i ] ) #NEWLINE# i += 1 #NEWLINE# #UNINDENT# tmp = sorted ( tmp , reverse = reverse ) #NEWLINE# self . entries_index_sorted = [ ] #NEWLINE# for t in tmp : #NEWLINE# #INDENT# self . entries_index_sorted . append ( t [ 2 ] )