Re: Fun with reverse sorts

2008-10-03 Thread bearophileHUGS
Chris Rebert: > So the improved code is: > your_list.sort(key=lambda elem: (elem[3], elem[2]), reverse=True) Better (untested): from operator import itemgetter ... your_list.sort(key=itemgetter(3, 2), reverse=True) Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list

Re: Fun with reverse sorts

2008-10-02 Thread David Di Biase
I did see that actually, I thought it was only applied to specifying default parameters and wasn't sure if it ALSO applied to putting it into a function. In a way however, I see what you're getting at - it's basically the same thing you're just specifying a default value the same way... Ok problem

Re: Fun with reverse sorts

2008-10-02 Thread Chris Rebert
On Thu, Oct 2, 2008 at 8:07 PM, David Di Biase <[EMAIL PROTECTED]> wrote: > Hi there, > > I'm sorting an expansive list descending according to a list of tuples. > Basically it has to sort the last value in the tuple (3) but if they are the > same then it should resort to using the second last valu

Fun with reverse sorts

2008-10-02 Thread David Di Biase
Hi there, I'm sorting an expansive list descending according to a list of tuples. Basically it has to sort the last value in the tuple (3) but if they are the same then it should resort to using the second last value (2). Now according to my very limited testing I've somewhat figured out that this