Python3: Using sorted(key=...)
Johannes Bauer
dfnsonfsduifb at gmx.de
Thu Aug 6 20:55:27 EDT 2009
Hello list,
I'm having trouble with a incredibly simple sort of a list containing
ints and tuples:
def myorder(x):
if type(x) == int:
return x
else:
return x[0]
odata = sorted([ (a, b) for (a, b) in data["description"].items() ],
key=myorder)
still says:
Traceback (most recent call last):
File "./genproto.py", line 81, in <module>
odata = sorted([ (a, b) for (a, b) in data["description"].items() ],
key=myorder)
TypeError: unorderable types: tuple() < int()
Why is that? Am I missing something very obvious?
Kind regards,
Johannes
--
"Du bist einfach nur lächerlich! Mit solchen albernen und hohlen Sätzen
kannst du mir nicht imprägnieren."
-- Hobbycholeriker Jens Fittig aka Wolfgang Gerber in de.sci.electronics
<4a6f44d0$0$12481$9b622d9e at news.freenet.de>
More information about the Python-list
mailing list