[Tutor] help for dictionary sorting program

Alan Gauld alan.gauld@blueyonder.co.uk
Fri Apr 18 17:58:59 2003


> def SortDict(adict):
>         """ this function sorts the frequency/key pairs in the
>             dictionary by highest to lowest frequency   """
>         counts = {}
>         for word in adict.items():

At this point word contains a tuple of key,value. I suspect 
you only want to extract the keys.

>                 if counts.has_key(word):

Especially since you are comparing with a key...

Alan G.