Re: [Tutor] help with sorted()

2008-08-19 Thread Emile van Sebille
Rick Pasotto wrote: I have a dictionary that looks like: d = {k:[v1,[v2,v3,v4]]} v1,v2,v3,v4 are integers. I want to print the dictionary sorted by v1, high to low. sorted(d,operator.itemgetter(0),reverse=True) You need to pass a compare function in... try for ii in sorted(d,lambda ii,jj: c

Re: [Tutor] help with sorted()

2008-08-17 Thread Kent Johnson
On 8/17/08, Rick Pasotto <[EMAIL PROTECTED]> wrote: > I have a dictionary that looks like: d = {k:[v1,[v2,v3,v4]]} > > v1,v2,v3,v4 are integers. > > I want to print the dictionary sorted by v1, high to low. Do you want just the keys, or the key/value pairs, or what? > sorted(d,operator.itemgetter

[Tutor] help with sorted()

2008-08-17 Thread Rick Pasotto
I have a dictionary that looks like: d = {k:[v1,[v2,v3,v4]]} v1,v2,v3,v4 are integers. I want to print the dictionary sorted by v1, high to low. sorted(d,operator.itemgetter(0),reverse=True) gives me the keys in some order different than if I just looped through the dictionary and not in key or