Esmail wrote:
items = [apple, car, town, phone] values = [5, 2, 7, 1] I would like to sort the 'items' list based on the 'values' list so that I end up with the following two list: items = [town, apple, car, phone] values = [7, 5, 2, 1]
Hello all, thanks for all the great suggestions. I used Diez's post as an opportunity to learn about zip and this this is the code I ended up drafting: li=zip(*sorted(zip(values, items), reverse=True)) new_items=list(li[1]) new_vals=list(li[0]) seems to work :-) Esmail -- http://mail.python.org/mailman/listinfo/python-list