title: Sort array and keep values of keys
body: <p>I have an array that looks like this:</p>
  
  <pre><code>Array
  (
      [team1] =&gt; Array
          (
              [points] =&gt; 10
              [players] =&gt; Array
                  (
                       ...
                  )
          )
  
      [team2] =&gt; Array
          (
              [points] =&gt; 23
              [players] =&gt; Array
                  (
                       ...
                  )
          )
  
      ... many more teams
  )
  </code></pre>
  
  <p>and I would like to sort the teams by the number of points each team has. I have tried this:</p>
  
  <pre><code>function sort_by_points($a,$b)
  {
      if ($a['points']==$b['points']) return 0;
          return ($a['points']&lt;$b['points'])?1:-1;
  }
  
  usort($this-&gt;wordswithdata, "sortbycount");
  </code></pre>
  
  <p>But that approach overrides the keys containing the teamnames and returns:</p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [points] =&gt; 23
              [players] =&gt; Array
                  (
                       ...
                  )
          )
  
      [1] =&gt; Array
          (
              [points] =&gt; 10
              [players] =&gt; Array
                  (
                       ...
                  )
          )
  
      etc...
  )
  </code></pre>
  
  <p>Is there any way to sort the array without overwriting the teamnames as the array keys?</p>