News for hackers. Stuff that matters.
Re:Ask HN: Good Python codebases to read? by rectangletangle on Thursday July 16, 2015 @05:00PM (#9899850)
A more idiomatic way to handle this is to arrange the items in the tuple by sort precedence, then restructure the data in the tuple after the sort.

>>> [(b, a) for a, b in sorted(((-(x2), x) for x in xrange(10) if 0 == x % 2))]

[(8, -64), (6, -36), (4, -16), (2, -4), (0, 0)]

However, ocasionally you still need a more complex sorting function. So lambdas are still handy, IMO.

There are no comments on this comment yet.