solution by <a href="mhtml:{154E1F55-D942-4CE9-9B8C-82060E1E80CE}mid://00000047/!x-usc:mailto:jadec.seven@gmail.com">jadec.seven@gmail.com</a> , China<br><br>values,items = zip( *sorted( zip (values,items)))<br><br>----- Original Message ----- <br>
From: "Esmail" <<a href="mhtml:{154E1F55-D942-4CE9-9B8C-82060E1E80CE}mid://00000047/!x-usc:mailto:ebonak@hotmail.com">ebonak@hotmail.com</a>><br>To: <<a href="mhtml:{154E1F55-D942-4CE9-9B8C-82060E1E80CE}mid://00000047/!x-usc:mailto:python-list@python.org">python-list@python.org</a>><br>
Sent: Tuesday, April 21, 2009 12:10 AM<br>Subject: sorting two corresponding lists?<br><br><br>> Hello all,<br>> <br>> I wonder if someone could help me with sorting two corresponding lists.<br>> <br>> For instance the first list contains some items, and the second list<br>
> contains their value (higher is better)<br>> <br>> items = [apple, car, town, phone]<br>> values = [5, 2, 7, 1]<br>> <br>> I would like to sort the 'items' list based on the 'values' list so<br>
> that I end up with the following two list:<br>> <br>> items = [town, apple, car, phone]<br>> values = [7, 5, 2, 1]<br>> <br>> So I would like to keep the corresponding value still corresponding<br>> after the sorting.<br>
> <br>> Is there an easy/nice/Pythonic way to do this?<br>> <br>> Thanks,<br>> Esmail<br>> <br>> --<br>> <a href="mhtml:{154E1F55-D942-4CE9-9B8C-82060E1E80CE}mid://00000047/!x-usc:http://mail.python.org/mailman/listinfo/python-list">http://mail.python.org/mailman/listinfo/python-list</a>