I know that in Python, if I have:
list_1 = [1,2,3]
list_2 = [2,3,4]
I can do the following to find the intersection between the two:
list(set(list_1) & set(list_2))
# = [2,3]
But there's one problem with that approach: sets don't maintain order the way that lists do. So if I actually have:
list_1 = [3,2,1]
list_2 = [2,3,4]
I get:
list(set(list_1) & set(list_2))
# = [2,3]
even though I'd prefer to have the order from the first list, ie.:
# = [3,2]
Is there an alternative intersection technique which keeps the resulting "intersection set" in the same order as the first list?