import numpy as np
fixedList = ['116','117','114','99','102','101','95']
unorderedList = ['99','116','117']
# isin returns a boolean array of the same shape as element
# that is True where an element of unorderedList is in fixedList and False otherwise.
mask = np.isin(np.array(fixedList), np.array(unorderedList))
#Now form new list using mask
newlist = (np.array(fixedList)[mask]).tolist()
def intersection(lst1, lst2):
lst3 = [value for value in lst1 if value in lst2]
return lst3
fixedList = ['116','117','114','99','102','101','95']
unorderedList = ['99','116','117']
print( intersection(fixedList,unorderedList))