I want to find out if an array is an ordered subset of another array:
[1,2]
is an ordered subset of[1,2,3]
[1,3]
is an ordered subset of[1,2,3]
[2,1]
is not an ordered subset of[1,2,3]
I've found some solutions to this, but every solution ignores the order. Every method I've seen so far ignores the order of the arrays:
[1,2,3] - [2,1] #=> [3]
[1,2,3] & [2,1] #=> [1,2]
[1,2,3].to_set.superset?([2,1].to_set) #=> true
Update: Based on the discussion below, I've updated my question.