[Tutor] Dictionary and List Question?

John P Speno speno at isc.upenn.edu
Thu Nov 13 08:07:42 EST 2003


On Wed, Nov 12, 2003 at 10:41:36PM -0500, John P Speno wrote:
> def my_sort(a, b):
>     return cmp(a[0], b[0])
> 
> l.sort(my_sort)

I forgot that by default, python's list sort method will sort a list of
sequences based on the first item in the sequence, so you can get rid of
the my_sort function, and just call l.sort().



More information about the Tutor mailing list