title: How to invert a permutation array in numpy
body: <p>Given a self-indexing (not sure if this is the correct term) numpy array, for example:</p>
  
  <pre><code>a = np.array([3, 2, 0, 1])
  </code></pre>
  
  <p>This represents this <a href="http://en.wikipedia.org/wiki/Permutation#Notation">permutation</a> (<code>=&gt;</code> is an arrow):</p>
  
  <pre><code>0 =&gt; 3
  1 =&gt; 2
  2 =&gt; 0
  3 =&gt; 1
  </code></pre>
  
  <p>I'm trying to make an array representing the inverse transformation without doing it "manually" in python, that is, I want a <em>pure</em> numpy solution. The result I want in the above case is:</p>
  
  <pre><code>array([2, 3, 1, 0])
  </code></pre>
  
  <p>Which is equivalent to</p>
  
  <pre><code>0 &lt;= 3                0 =&gt; 2
  1 &lt;= 2       or       1 =&gt; 3
  2 &lt;= 0                2 =&gt; 1
  3 &lt;= 1                3 =&gt; 0
  </code></pre>
  
  <p>It seems so simple, but I just can't think of how to do it. I've tried googling, but haven't found anything relevant.</p>