Velocity Reviews > Proposed implementation for an Ordered Dictionary

# Proposed implementation for an Ordered Dictionary

Paul Rubin
Guest
Posts: n/a

 03-01-2009
"Colin J. Williams" <(E-Mail Removed)> writes:
> # print [mydict[x] for x in sorted(mydict.keys)] Instance object
> is not iterable

It was a typo. Use:

print [mydict[x] for x in sorted(mydict.keys())]

Michele Simionato
Guest
Posts: n/a

 03-01-2009
On Mar 1, 1:43*am, Paul Rubin <http://(E-Mail Removed)> wrote:
> "Colin J. Williams" <(E-Mail Removed)> writes:
>
> > * * *# print [mydict[x] for x in sorted(mydict.keys)] Instance object
> > is not iterable

>
> It was a typo. *Use:
>
> * * print [mydict[x] for x in sorted(mydict.keys())]

Even better

print [mydict[x] for x in sorted(mydict)]

Colin J. Williams
Guest
Posts: n/a

 03-01-2009
Michele Simionato wrote:
> On Mar 1, 1:43 am, Paul Rubin <http://(E-Mail Removed)> wrote:
>> "Colin J. Williams" <(E-Mail Removed)> writes:
>>
>>> # print [mydict[x] for x in sorted(mydict.keys)] Instance object
>>> is not iterable

>> It was a typo. Use:
>>
>> print [mydict[x] for x in sorted(mydict.keys())]

>
> Even better
>
> print [mydict[x] for x in sorted(mydict)]

Both Paul Rubin and Michele Simionato
produce the same result but neither
produces what was originally suggested:

def seqValues(self):
''' To return the values, with
their keys, sorted by value. '''
v= [(it[1], it[0]) for it in
self.items()]
v.sort()
return v

Colin W.