[Tutor] I'd like to sort (symbol, address) set by address [

Sean 'Shaleh' Perry shalehperry@attbi.com
Mon, 15 Jul 2002 12:23:37 -0700 (PDT)


> 
> By the way, we can also write this sort function by taking advantage of
> Python's cmp() comparison function:
> 
>###
> def compare_by_second(a, b):
>     return cmp(a[1], b[1])
>###
> 
> which, if I didn't put any typos in there, should do the same thing as
> Sean's sorter() function.
> 

Thanks Danny.  I was trying to demonstrate how to write a sorter() style
function.  Plus I often find that a simple call to cmp() is not sufficient for
most sorting needs 'sort by 2nd then 3rd column in lower case' kind of stuff.

But might as well use it when it lets you do a one liner (-: