fork download
  1. <?php
  2.  
  3. $p = array();
  4. $p[] = array('team_id' => 1, 'points' => 5);
  5. $p[] = array('team_id' => 2, 'points' => 3);
  6. $p[] = array('team_id' => 3, 'points' => 6);
  7. $p[] = array('team_id' => 4, 'points' => 2);
  8. $p[] = array('team_id' => 5, 'points' => 4);
  9. $p[] = array('team_id' => 6, 'points' => 1);
  10.  
  11. $points = array();
  12.  
  13. foreach ($p as $key => $row)
  14. {
  15. $points[$key] = $row['points'];
  16. }
  17.  
  18. array_multisort($points, SORT_NUMERIC, SORT_DESC, $p);
  19.  
  20. print_r($p);
Success #stdin #stdout 0.02s 13064KB
stdin
Standard input is empty
stdout
Array
(
    [0] => Array
        (
            [team_id] => 3
            [points] => 6
        )

    [1] => Array
        (
            [team_id] => 1
            [points] => 5
        )

    [2] => Array
        (
            [team_id] => 5
            [points] => 4
        )

    [3] => Array
        (
            [team_id] => 2
            [points] => 3
        )

    [4] => Array
        (
            [team_id] => 4
            [points] => 2
        )

    [5] => Array
        (
            [team_id] => 6
            [points] => 1
        )

)