Chris Rebert:
> You use the `key` argument to .sort():
> L2.sort(key=lambda item: item[1])

I like the lambda because it's a very readable solution that doesn't
require the std lib and it doesn't force the programmer (and the
person that reads the code) to learn yet another thing/function.

But I can suggest to also look for operator.itemgetter.

------------
In C# a syntax for lambdas may become a little shorter, but the
parsing may become less easy:
L2.sort(key = sub => sub[1])

In Mathematica they use the & to define lambdas, and #1, #2, etc, to
denote the arguments.

Bye,
bearophile
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to