Sorting two related lists I have code that sorts two lists related with each other

"""
    list1 reperesents customer
    list2 reperesents amount of products they have brought
"""

list1=['a','c','e','i','o','u']
list2=[12,23,45,10,7,2]
list3=[]
for i in range(0,len(list1)):
        list3.append([list1[i],list2[i]])
print list3
"""
    [['a', 12], ['c', 23], ['e', 45], ['i', 10], ['o', 7], ['u', 2]]
"""
list3=sorted(list3,key=lambda x: list3[list3.index(x)][1])

print(list3)
"""
    [['u', 2], ['o', 7], ['i', 10], ['a', 12], ['c', 23], ['e', 45]]
"""
for i in range(0.len(list3)):
    list1[i]=list3[i][0]
    list2[i]=list3[i][1]

print list1
print list2


List1 is the customers' names
List2 is the number of products each customer bought

So:


'a' bought 12 products
'c' bought 23 products


And so on.

Is there a better way to do this?
You should probably just change how the data is stored. You should have one list which contains all of a customers data. For instance, a dictionary that follows this template:

{"name": "a", "purchased": 12}


If you had a list of those, it would be trivial to sort them, using the list sorting functions.

customer_data = [
                    {"name": "a", "purchased": 12},
                    {"name": "c", "purchased": 23},
                    {"name": "o", "purchased": 7},
                ]
customer_data.sort(key=lambda customer: customer["purchased"])
print customer_data
# [{'name': '0', 'purchased': 7}, {'name': 'a', 'purchased': 12}, {'name': 'c', 'purchased': 23}]