Ask Your Question

Revision history [back]

You can provide a key function to sort with, as follows (say you want the most frequent letter first):

sage: sorted(table, key=table.get, reverse=True)
['E', 'T', 'A', 'O', 'I', 'N', 'S', 'H', 'R', 'D', 'L', 'C', 'U', 'M', 'W', 'F', 'G', 'Y', 'P', 'B', 'V', 'K', 'J', 'Q', 'X', 'Z']

You can provide a key function to sort with, as follows (say you want the most frequent letter first):

sage: sorted(table, key=table.get, reverse=True) 
['E', 'T', 'A', 'O', 'I', 'N', 'S', 'H', 'R', 'D', 'L', 'C', 'U', 'M', 'W', 'F', 'G', 'Y', 'P', 'B', 'V', 'K', 'J', 'Q', 'X', 'Z']

'Z']