On Fri, 18 Dec 2009 23:00:42 -0000, David Robinow <drobi...@gmail.com> wrote:

I won't engage in any arguments about pythonicity but it seems simpler
if you convert to a list of tuples right away.

d = {1:('a', 1, 12), 5:('r',21,10), 2:('u',9,8)}
l = [(x, d[x]) for x in d.keys()]

which is a long way of writing "l = d.items()", or "l = list(d.items())" if you're using Python 3. :-)

def third(q):
    return q[1][2]

s = sorted(l, key=third)
print s


--
Rhodri James *-* Wildebeeste Herder to the Masses
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to