I am trying to sort an array using the usort function...what I would like to accomplish is sorting the following array by the [score]. The output I get with print_r is as follows:
Array (
[0] => Array ( [name] => Vin [team] => [score] => 32 [deaths] => 2 )
[1] => Array ( [name] => Ali_Akbah [team] => [score] => 27 [deaths] => 9 )
[2] => Array ( [name] => Nailbiter [team] => [score] => 11 [deaths] => 7 )
[3] => Array ( [name] => Daniel [team] => [score] => 16 [deaths] => 4 )
[4] => Array ( [name] => Mazanetz [team] => [score] => 24 [deaths] => 9 )
[5] => Array ( [name] => Camouflage [team] => [score] => 9 [deaths] => 2 )
[6] => Array ( [name] => Chaos [team] => RR [score] => 11 [deaths] => 11 )
[7] => Array ( [name] => IlluminatusBR [team] => PELOPES [score] => 6 [deaths] => 1 )
[8] => Array ( [name] => JL [team] => [score] => 8 [deaths] => 8 )
[9] => Array ( [name] => Saffrons_Curse [team] => [score] => 0 [deaths] => 0 )
)
I am using the following defined sorting function:
function scoresort ($a, $b) {
if ($a[score] == $b[score]) return 0;
if ($a[score] > $b[score]) {
return -1;
} else {
return 1;
}
}
and the following call to the defined sort:
usort ($ofp->m_playerinfo,"scoresort");
obviously I am doing something wrong as it isnt doing what its supposed to...Thanks in advance for any help you may be able to offer!