Sorting x lists based on one list ... maybe an example would make sense:
Larry Bates
lbates at syscononline.com
Tue May 17 17:57:51 EDT 2005
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