title: Sorting values in dataframe by order of values in another dataframe R
body: <p>I would like to sort values in columns of the <code>xy1</code> dataframe, based on the increasing order of values in columns of the <code>xy</code> dataframe.</p>
  
  <pre><code>x &lt;- c(3,1,7,45,22,2)
  y &lt;- c(23,65,1,23,2,11)
  xy &lt;- data.frame(x,y)
  
  x1 &lt;- c(0.34,0.3,0.7,0.22,0.67,0.87)
  y1 &lt;- c(0.4,0.13,0.17,0.72,0.61,0.7)
  xy1 &lt;- data.frame(x1,y1)
  
      &gt; xy
         x  y
      1  3 23
      2  1 65
      3  7  1
      4 45 23
      5 22  2
      6  2 11
      &gt; xy1
          x1   y1
      1 0.34 0.40
      2 0.30 0.13
      3 0.70 0.17
      4 0.22 0.72
      5 0.67 0.61
      6 0.87 0.70
  </code></pre>
  
  <p>The following is a new data.frame result that I desire - note it deals with repeated observations (two the same values in <code>y</code>). <code>x1</code> and <code>y1</code> are now sorted according to the order of values in each column of <code>xy</code> dataframe.</p>
  
  <pre><code>    x1   y1
  1 0.30 0.17
  2 0.87 0.61
  3 0.34 0.70
  4 0.70 0.40
  5 0.67 0.72
  6 0.22 0.13
  </code></pre>