Well, it's like the manual says:
The comparison function must return an integer less than, equal to, or greater than zero if the first argument is considered to be respectively less than, equal to, or greater than the second.
Everytime [man]usort[/man] needs to compare two items in the list to decide what order they should be in once they're sorted. If compare($a,$b) returns a number less than zero, then $a is deemed less than $b. Given that example I'm sure you can work out what happens in the other two cases.
wheeler08 wrote:Here is an example of the function I tried using when calling usort($scores, 'compare').
And what was the result? Your comparison function looks reasonable; though you could simplify it to just
function compare($x, $y)
{
return $x['wins']-$y['wins'];
}
Your problem is that you're trying to sort a two dimensional array into a linear order - just knowing if one item is less than another won't tell you if it should be above or to the left. Besides, you'll lose information in the process: even if you could define such an order $eventID and $teamID will be lost, because they are the current, unsorted positions in the array).
Try an array like this:
$scores[] = array(
'eventID' = $eventID,
'teamID' = $teamID,
'team' => $teamName,
'wins' => $wins,
...
);