Re: Getting sorting order

2008-07-01 Thread Paddy
On Jul 1, 8:26 pm, Tobiah <[EMAIL PROTECTED]> wrote: > master,slave1,slave2=zip(*x) > > What does the asterisk do here? > > Thanks > ** Posted fromhttp://www.teranews.com** Hi Tobiah, I blogged extensively on this zip(*x) trick here: http://paddy3118.blogspot.com/2007/02/unzip-un-needed-in-

Re: Getting sorting order

2008-07-01 Thread Nick Craig-Wood
Tobiah <[EMAIL PROTECTED]> wrote: > master,slave1,slave2=zip(*x) > > What does the asterisk do here? > > Thanks > ** Posted from http://www.teranews.com ** Instead of passing a single argument x to zip() you can think of it unpacking the list x and passing len(x) arguments to zip. So if

Re: Getting sorting order

2008-07-01 Thread Tobiah
master,slave1,slave2=zip(*x) What does the asterisk do here? Thanks ** Posted from http://www.teranews.com ** -- http://mail.python.org/mailman/listinfo/python-list

Re: Getting sorting order

2008-06-30 Thread leodp
> >>> x=zip(master,slave1,slave2) > >>> x.sort() > >>> master,slave1,slave2=zip(*x) > --Mark So nice is Python. Leo -- http://mail.python.org/mailman/listinfo/python-list

Re: Getting sorting order

2008-06-30 Thread Mark Tolonen
"leodp" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Or provide a better explanation and an example. Do you mean something like this? Hi Peter, a small example: master=[1,4,3,2] slave1=['d','c','b','a'] slave2=[1,2,3,4] master.sort() # this is ok, but does not return info

Re: Getting sorting order

2008-06-30 Thread leodp
> >>> master_index.sort(key=master.__getitem__) that was it! Thanks Peter, leodp -- http://mail.python.org/mailman/listinfo/python-list

Re: Getting sorting order

2008-06-30 Thread Peter Otten
leodp wrote: > >> Or provide a better explanation and an example. Do you mean something >> like this? >> > > Hi Peter, > a small example: > > master=[1,4,3,2] > slave1=['d','c','b','a'] > slave2=[1,2,3,4] > > master.sort() # this is ok, but does not return infos on how the list > was sorted >

Re: Getting sorting order

2008-06-30 Thread leodp
> Or provide a better explanation and an example. Do you mean something like > this? > Hi Peter, a small example: master=[1,4,3,2] slave1=['d','c','b','a'] slave2=[1,2,3,4] master.sort() # this is ok, but does not return infos on how the list was sorted slave1.sort(key=_maybe_something_here_ref

Re: Getting sorting order

2008-06-30 Thread Peter Otten
leodp wrote: > I cannot find anything on this: > I have a few lists, and would like to sort one of them (sorting-master > list). > Then I would like to sort all other lists according to how the first > one was sorted (sorting-slave lists). > > Is there a standard way to do that? > From what I kno

Getting sorting order

2008-06-30 Thread leodp
Hi all, I cannot find anything on this: I have a few lists, and would like to sort one of them (sorting-master list). Then I would like to sort all other lists according to how the first one was sorted (sorting-slave lists). Is there a standard way to do that? >From what I know sort() and sorted(