Sorting x lists based on one list ... maybe an example would make sense:

Philippe C. Martin philippe at philippecmartin.com
Tue May 17 18:41:13 EDT 2005


I had no clue this was feasible!

Python folks should get the Nobel price !




Larry Bates wrote:

> Why not merge the lists together using zip() and then
> sort.
> 
> info=zip(l1, l2, l3)
> info.sort()
> info.reverse
> 
> Larry Bates
> 
> Philippe C. Martin wrote:
>> l1 = ['a','b','c']
>> l2 = ['toto','titi','tata'] # 'toto' refers to 'a', 'titi' to b' ....
>> l3 = ['foo','bar','doe'] # 'foo' refers to 'a' ........
>> 
>> I want to reverse sort l1 and have l2 and l3 follow accordingly.
>> 
>> Regards,
>> 
>> Philippe
>> 
>> 
>> 
>> 
>> 
>> 
>> Philippe C. Martin wrote:
>> 
>> 
>>>Hi,
>>>
>>>I'm looking for an easy algorithm - maybe Python can help:
>>>
>>>I start with X lists which intial sort is based on list #1.
>>>
>>>I want to reverse sort list #1 and have all other lists sorted
>>>accordingly.
>>>
>>>Any idea is welcome.
>>>
>>>Regards,
>>>
>>>Philippe
>> 
>>




More information about the Python-list mailing list