title: How to compare order of elements in two vectors in R?
body: <p>I have two vectors with the same elements but in different order, how can I find the new position of the elements ? <code>which()</code> should do the trick but I'm unable to figure out how to do that, any idea ?</p>
  
  <p>For example :</p>
  
  <pre><code>v1 &lt;- c("paris", "new york", "london", "sidney")
  v2 &lt;- c("sidney", "new york", "paris", "london")
  
  &gt; which(v1 %in% v2)
  [1] 1 2 3 4
  &gt; which(v1 == v2)
  integer(0)
  </code></pre>
  
  <p>What I'm trying to do is something like  :</p>
  
  <pre><code>&gt; find_new_position(v1, v2)
  [1] 3 2 4 1
  </code></pre>