Sorting x lists based on one list ... maybe an example would make sense:

Ron Adam rrr at ronadam.com
Wed May 18 18:37:05 EDT 2005


Steven Bethard wrote:

> Ron Adam wrote:
>>    grades.sort(lambda x,y: cmp(students[x[1]][0], students[y[1]][0])) 

> Assuming that students[x[1]][0] is what you want to sort on, this may 
> also be written as:
> 
>     grades.sort(key=lambda x: students[x[1]][0])
	

Yes, I figured there was a better way to write it.

Thanks, Steve




More information about the Python-list mailing list