Steve Horne sh at
Wed Dec 6 12:25:57 CET 2000

On Wed, 06 Dec 2000 09:07:57 GMT, "Alfred" <scj at> wrote:

>I'm trying to sort a List of List, on the third col, but I don't find how to
>do this.

You can specify an alternative comparison function to the sort method.
The easiest way to do this is with a lambda...

l.sort (lambda a, b : a[2] < b[2])

For comparison, the following should do the same as the basic sort
(but slower)...

l.sort (lambda a, b : a < b)

Steve Horne
Home : steve at
Work : sh at

More information about the Python-list mailing list