Nick Craig-Wood: > Since no-one mentioned it and its a favourite of mine, you can use the > decorate-sort-undecorate method, or "Schwartzian Transform"
That is what the aforementioned key argument to sort is: a built-in
decorate-sort-undecorate.
>>> lst = [[1,4],[3,9],[2,5],[3,2]]
>>> print lst
[[1, 4], [3, 9], [2, 5], [3, 2]]
>>> lst.sort(key=lambda x: x[1])
>>> print lst
[[3, 2], [1, 4], [2, 5], [3, 9]]
Neil
--
http://mail.python.org/mailman/listinfo/python-list
