MRAB schrieb: > Johannes Bauer wrote: >> 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) >> > You're sorting a list of tuples (key/value pairs), so 'myorder' is > always given a tuple.
Oh good lord! You're right... I meant def myorder(x): if type(x[0]) == int: return x[0] else: return x[0][0] Thanks for your help, 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$9b622...@news.freenet.de> -- http://mail.python.org/mailman/listinfo/python-list