[Tutor] .sort(key = ???)
Dave S
pythontut at pusspaws.net
Thu Nov 16 23:22:06 CET 2006
Hi,
I have a bunch of lists within lists that I need to sort ref item [4], I can't
access my code at the moment but I basically ...
a = [[...], [...], .... ]
a.sort(item4)
def item4(a,b):
return a[4], b[4]
Having googled I think there is a better way of doing this with the key
attribute
a.sort(key= ?? )
I cant get a handle on how key works or how to code it for my needs.
Can anyone help ?
Thanks in advance
Dave
More information about the Tutor
mailing list