sorting a dictionary

Anton Vredegoor anton at vredegoor.doge.nl
Tue Feb 4 07:22:03 EST 2003


On Tue, 04 Feb 2003 12:35:42 +0100, anton at vredegoor.doge.nl (Anton
Vredegoor) wrote:

the last line of the function should be:

def get_highest(D):
    def kmax(a,b):
        if D.get(a)<D.get(b): return b
        return a
    return reduce(kmax,D,None)

Because now it gives a traceback if called with for example [1] as
input. Lose ambiguity only as much as necessary, anything more would
be aji-keshi :-) 

Regards,

	Anton.






More information about the Python-list mailing list