Colin J. Williams wrote:

> Sometimes, it's useful to be able to
> obtain the data in the sorted sequence.
> 
> You might consider adding functionality
> like:
> 
> def seqItems(self):
> '''To return the items, sorted
> by key. '''
> return [self[k] for k in
> self.seqKeys()]

Amazingly, the Python time-machine provides such functionality! Using just a
handful of pre-existing pieces, you can do this:

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

and any other sequence you might need. That's the beauty of a general
purpose programming language. You don't need everything to be a built-in
*wink*



-- 
Steven

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to