title: sort php array by index
body: <p>I'm having some difficulties sorting a simple array that looks like this:</p>
  
  <pre><code>array(4) {
    [32]=&gt;
    string(1) "1"
    [34]=&gt;
    string(1) "2"
    [35]=&gt;
    string(1) "1"
    [33]=&gt;
    string(1) "0"
  }
  </code></pre>
  
  <p>I just want to sort it by the index so it would look like this:</p>
  
  <pre><code>array(4) {
    [32]=&gt;
    string(1) "1"
    [33]=&gt;
    string(1) "0"
    [34]=&gt;
    string(1) "2"
    [35]=&gt;
    string(1) "1"
  }
  </code></pre>
  
  <p>I tried using <code>sort($votes);</code> but this seems to remove the index and my array looks like this afterwards:</p>
  
  <pre><code>array(4) {
    [0]=&gt;
    string(1) "0"
    [1]=&gt;
    string(1) "1"
    [2]=&gt;
    string(1) "1"
    [3]=&gt;
    string(1) "2"
  }
  </code></pre>
  
  <p>So what would be the best way of sorting this array so that the index is still the same, but sorted?</p>