nDimensional sparse histogram in python.

Kirk McDonald mooquack at suad.org
Wed Feb 1 22:48:19 EST 2006


KraftDiner wrote:
> The dictionary is sorted by the point key.
> Is there a way to sort the dictionary by the value?
> Seems to me this goes against the purpose of a dictionary but....
> thats what I need to do..
> 

Well, it's probably not all that efficient, but it is simple code:

sortedList = [(v, k) for k, v in self.histo.items()]
sortedList.sort()

Should do it...

-Kirk McDonald



More information about the Python-list mailing list