Sorting lists of lists by columns

Thomas Guettler zopestoller at thomas-guettler.de
Tue Mar 4 11:11:34 EST 2003


Stephen Boulet schrieb:
> Is there any list method available to sort lists of lists by columns? 
> I'm thinking of a spreadsheet-type function where you might sort rows by 
> the column x, y, and then z.

Does this help you?

def mycmp(a, b):
	return cmp(a[4], b[4])
mylist.sort(mycmp)

  thomas






More information about the Python-list mailing list