Missing the functional mind set
Aahz Maruch
aahz at panix.com
Sat Mar 3 16:25:06 EST 2001
In article <mlb2at8ptrr7sh5dgq8qlk2201kquh6tfl at 4ax.com>,
Daniel Klein <danielk at aracnet.com> wrote:
>The purpose of this code is to return a list of dictionary values sorted by
>key, resulting in 'templist'.
>
>>>> d = {3: 'd', 2: 'b', 1: 'a', 0: 'z'}
>>>> templist = []
>>>> for n in range(len(d)):
> templist.append(d[n])
For a somewhat more general solution that's slightly less efficient, sort
d.items().
--
--- Aahz (Copyright 2001 by aahz at pobox.com)
Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6
Nostalgia just ain't what it used to be
More information about the Python-list
mailing list