[EMAIL PROTECTED] wrote:
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.
Since itemgetter is builtin, it will probably run faster, though the
O(nlogn) time for sorting will override the O(n) time for key calls.
--
http://mail.python.org/mailman/listinfo/python-list