[Tutor] Sorting a list of lists aka nested lists

Jim Roush ja_roush at mminternet.com
Sat Aug 13 22:28:31 CEST 2005


I have a python script that creates a list of lists like so:

    Quant.append( [ db_ticker, stock_close, MTD, 0, QTD, 0, YTD, 0, 0, 0 ] )

After Quant is created, I want to sort it by MTD.  If I use a simple 
Quant.sort(), I assume its going to sort by 'db_ticker' which is not 
what I want.

I've been trying to figure out how to use the cmp() in a list sort 
method and I have failed to understand.

Please help.




-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.338 / Virus Database: 267.10.8/71 - Release Date: 8/12/2005



More information about the Tutor mailing list