Another approach in addition to dcg's answer would be as follows:
Ref = [3, 2, 1, 12, 11, 10, 9, 8, 7, 6, 5, 4]
Input = [9, 5, 2, 3, 10, 4, 11, 8]
ref = set(Ref)
inp = set(Input)
sorted_list = sorted(ref.intersection(inp), key = Ref.index)
This outputs to:
[3, 2, 11, 10, 9, 8, 5, 4]
Here you convert the lists into sets, find their intersection, and sort them. The set is sorted based on the 'Ref' list's indexing.