This function returns a tuple of value-key pairs, sorted by value:
>>> x = {'a':3, 'b':2, 'c':4}
>>> def sortByValue(myDict):
return sorted( [(v,k) for k,v in myDict.items()] )If you want to get the first two value-key pairs: >>> sortByValue(x)[:2] [(2, 'b'), (3, 'a')] Hope this helps... Luis -- http://mail.python.org/mailman/listinfo/python-list
