title: Reorder a square array using a sorted 1D array
body: <p>Let's say I have a symmetric n-by-n array <code>A</code> and a 1D array <code>x</code> of length n, where the rows/columns of <code>A</code> correspond to the entries of <code>x</code>, and <code>x</code> is ordered. Now assume both <code>A</code> and <code>x</code> are randomly rearranged, so that the rows/columns still correspond but they're no longer in order. How can I manipulate <code>A</code> to recover the correct order?</p>
  <p>As an example: <code>x = array([1, 3, 2, 0])</code> and</p>
  <pre><code>A = array([[1, 3, 2, 0],
             [3, 9, 6, 0],
             [2, 6, 4, 0],
             [0, 0, 0, 0]])
  </code></pre>
  <p>so the mapping from <code>x</code> to <code>A</code> in this example is <code>A[i][j] = x[i]*x[j]</code>. <code>x</code> should be sorted like <code>array([0, 1, 2, 3])</code> and I want to arrive at</p>
  <pre><code>A = array([[0, 0, 0, 0],
             [0, 1, 2, 3],
             [0, 2, 4, 6],
             [0, 3, 6, 9]])
  </code></pre>