let's suppose you have to sort list X based on parallel list Y.
xxxxxxxxxx
X = ["a", "b", "c", "d", "e", "f", "g", "h", "i"]
Y = [ 0, 1, 1, 0, 1, 2, 2, 0, 1]
Z = [x for _,x in sorted(zip(Y,X))]
print(Z) # ["a", "d", "h", "b", "c", "e", "i", "f", "g"]
For 2 list of same size and with any type
xxxxxxxxxx
X = ["a", "b", "c", "d", "e", "f", "g", "h", "i"]
Y = [ 0, 1, 1, 0, 1, 2, 2, 0, 1]
Z = [x for _,x in sorted(zip(Y,X)), key=lambda pair: pair[0])]
print(Z) # ["a", "d", "h", "b", "c", "e", "i", "f", "g"]
But this question can also mean that you want to sort a list with another one that have the same elements type but different size.
Exemple: you want to sort letters in a custom order
xxxxxxxxxx
list_ = ['a', 'e', 'e', 'f', 'x', 'e', 'x']
order = 'e', 'f', 'x', 'a'
sorted_list = sorted(list_, key=order.index)
print(sorted_list) # ['e', 'e', 'e', 'f', 'x', 'x', 'a']