title: Sort a pandas DataFrame by a column in another dataframe - pandas
body: <p>Let's say I have a Pandas DataFrame with two columns, like:</p>
  
  <pre><code>df = pd.DataFrame({'a': [1, 2, 3, 4], 'b': [100, 200, 300, 400]})
  print(df)
  </code></pre>
  
  <hr>
  
  <pre><code>   a    b
  0  1  100
  1  2  200
  2  3  300
  3  4  400
  </code></pre>
  
  <p>And let's say I also have a Pandas Series, like:</p>
  
  <pre><code>s = pd.Series([1, 3, 2, 4])
  print(s)
  </code></pre>
  
  <hr>
  
  <pre><code>0    1
  1    3
  2    2
  3    4
  dtype: int64
  </code></pre>
  
  <p>How can I sort the <code>a</code> column to become the same order as the <code>s</code> series, with the corresponding row values sorted together?</p>
  
  <p>My desired output would be:</p>
  
  <pre><code>   a    b
  0  1  100
  1  3  300
  2  2  200
  3  4  400
  </code></pre>
  
  <p>Is there any way to achieve this?</p>
  
  <p><strong>Please check self-answer below.</strong></p>