Re: sort problem

2005-10-20 Thread Lasse Vågsæther Karlsen
How about: list.sort(key=lambda x: x[3]) Does that work? -- http://mail.python.org/mailman/listinfo/python-list

Re: sort problem

2005-10-20 Thread Michele Petrazzo
Lasse Vågsæther Karlsen wrote: > How about: > > list.sort(key=lambda x: x[3]) > > Does that work? > Yes, on my linux-test-box it work, but I my developer pc I don't have the 2.4 yet. I think that this is a good reason for update :) Thanks, Michele -- http://mail.python.org/mailman/listinfo/py

Re: sort problem

2005-10-20 Thread Kent Johnson
Michele Petrazzo wrote: > Lasse Vågsæther Karlsen wrote: > >> How about: >> >> list.sort(key=lambda x: x[3]) Better to use key=operator.itemgetter(3) > Yes, on my linux-test-box it work, but I my developer pc I don't have > the 2.4 yet. I think that this is a good reason for update :) or learn

Re: sort problem

2005-10-21 Thread Michele Petrazzo
Kent Johnson wrote: > or learn about decorate-sort-undecorate: > > lst = [ ...whatever ] lst = [ x[3], i, x for i, x in enumerate(lst) ] > I think that here the code must be changed (for the future): lst = [ (x[3], i, x) for i, x in enumerate(lst) ] > lst.sort() lst = [ x for _, _, x in lst ]

Re: sort problem

2005-10-21 Thread Alex Martelli
Michele Petrazzo <[EMAIL PROTECTED]> wrote: > Lasse Vågsæther Karlsen wrote: > > How about: > > > > list.sort(key=lambda x: x[3]) > > > > Does that work? > > Yes, on my linux-test-box it work, but I my developer pc I don't have > the 2.4 yet. I think that this is a good reason for update :) Up