You can't get a dictionary ordered by values, but you can get a list of key-value pairs ordered by value:
def sortByValue(myDict): x = sorted( [(v,k) for k,v in myDict.items()] ) return [(k,v) for v,k in x] For getting only the first two pairs: sortByValue(x)[:2] Hope this helps... Luis -- http://mail.python.org/mailman/listinfo/python-list