Say I have 2 arrays like this:
# base set
a = [1, 2, 3, 4, 5, 6, 7, 8, 9]
# sub set
b = [5, 1, 8, 3]
What's the optimal way to sort b to the same order as a?
a.sort_like(b) #=> [1, 3, 5, 8]
What is this operation called?
Say I have 2 arrays like this:
# base set
a = [1, 2, 3, 4, 5, 6, 7, 8, 9]
# sub set
b = [5, 1, 8, 3]
What's the optimal way to sort b to the same order as a?
a.sort_like(b) #=> [1, 3, 5, 8]
What is this operation called?