I've had a look at other similar questions already but haven't been able to apply the answers to my program. At the moment the frequencies are printed in ascending order, what do I change to make it print it in descending order?
from sys import argv
frequencies = {}
for ch in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':
frequencies[ch] = 0
for filename in argv[1:]:
try:
f = open(filename)
except IOError:
print 'skipping unopenable', filename
continue
text = f.read()
f.close()
for ch in text:
if ch.isalpha():
ch = ch.upper()
frequencies[ch] = frequencies[ch] + 1
for ch in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':
print ch, frequencies[ch]
Thanks in advance.