First time here? Check out the FAQ!

Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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']

click to hide/show revision 2
No.2 Revision

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']