I want to sort an array in particular order given in another array.
EX: consider an array
a=["one", "two", "three"]
b=["two", "one", "three"]
Now I want to sort array 'a' in the order of 'b', i.e
a.each do |t|
# It should be in the order of 'b'
puts t
end
So the output should be
two
one
three
Any suggestions?
ain the order found inb, well, iterateband you're done :-) So I guess there are more conditions, maybe items in arrays do not match? is not a "==" between objects what you need but a different kind of equality? show some more meaningful examples.