#NEWLINE# def sort( self , key , reverse = False ) : #NEWLINE# #INDENT# '\n        Sort the current list of items using the key function ``key``. If\n        ``reverse`` is true the sort order is reversed.\n        ' #NEWLINE# row = self . GetGridCursorRow ( ) #NEWLINE# col = self . GetGridCursorCol ( ) #NEWLINE# curitem = self . table . items [ row ] #NEWLINE# def realkey( item ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# return key ( item ) #NEWLINE# #UNINDENT# except ( KeyboardInterrupt , SystemExit ) : #NEWLINE# #INDENT# raise #NEWLINE# #UNINDENT# except Exception : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# #UNINDENT# try : #NEWLINE# #INDENT# self . table . items = ipipe . deque ( sorted ( self . table . items , key = row , reverse = reverse ) ) #NEWLINE# #UNINDENT# except TypeError as exc : #NEWLINE# #INDENT# self . error_output ( ( 'Exception encountered: %s' % exc ) ) #NEWLINE# return #NEWLINE# #UNINDENT# for ( i , item ) in enumerate ( self . table . items ) : #NEWLINE# #INDENT# if ( item is curitem ) : #NEWLINE# #INDENT# self . SetGridCursor ( i , col ) #NEWLINE# self . MakeCellVisible ( i , col ) #NEWLINE# self . Refresh ( )