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?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…