#NEWLINE# def get_popular( self , max_items = None ) : #NEWLINE# #INDENT# 'Return the results as as a list of ``(count, item)`` pairs, with the\n        most frequently occurring items first.\n\n        If ``max_items`` is provided, return no more than that many items.\n        ' #NEWLINE# data = [ ( x [ 1 ] , x [ 0 ] ) for x in self . result . items ( ) ] #NEWLINE# data . sort ( key = ( lambda x : ( ( - x [ 0 ] ) , x [ 1 ] ) ) ) #NEWLINE# if max_items : #NEWLINE# #INDENT# return self [ : max_items ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return data