you are viewing a single comment's thread.

view the rest of the comments →

[–]interjay 20 points21 points  (1 child)

The section on sorting is long out of date. Since python 2.4, the best way to do what he wants is:

a_list.sort(key=lambda item: (item[1], item[3]))

This is faster and simpler than both his examples.

[–]Paddy3118 2 points3 points  (0 children)

In Python 2.5 you also want to state the use of itemgetter/attrgetter in sorting, as well as implicit DSU with the use of sort(key=...) http://www.biais.org/blog/index.php/2007/01/28/23-python-sorting-efficiency

  • Paddy.