# Sort two lists one string other float

I have two lists

``````one = ['allen', 'steve', 'george', 'max']
two = [88.63, 33.99, 72.66, 92.11]
``````

I would like two lists sorted as below.

``````one = ['max', 'allen', 'george', 'steve']
two = [92.11, 88.63, 72.66 33.99]
``````

What I have tried

``````one, two = sorted(zip(one, two))
``````

One way of doing that:

``````one, two = zip(*sorted(zip(one, two), key=lambda tup: tup, reverse=True))
``````

You could combine the lists into a matrix and then sort the matrix using the numbers. The matrix is a 2D list that would group each number with a name. You can make this matrix using a list comprehension

``````combinedList = [[one[x], two[x]] for x in range(len(two))]
``````

output:

``````[['max', 92.11], ['allen', 88.63], ['george', 72.66], ['steve', 33.99]]
``````

Then, sort the list using the 2nd item in each entry (index 1)

``````outputList = sorted(combinedList, key=lambda x: x)
``````

output:

``````[['steve', 33.99], ['george', 72.66], ['allen', 88.63], ['max', 92.11]]
``````

For further processing, you could once again split this list back into list one and two, but sorted. Again, using list comprehension

``````one = [x for x in outputList]
two = [x for x in outputList]
``````

output:

``````['steve', 'george', 'allen', 'max']
[33.99, 72.66, 88.63, 92.11]
``````