Bug in sorting of standings in volleyball
-
Hi,
I think I have found a bug in the sorting of the volleyball standings. I searched in the forum here and found that some people had the same problem as I had, unfortunately the threads were mostly 1-2 years old and no one could help them back then.
The problem appears when two teams have the same amount of points. Next variable to sorty by should be the difference in set points. Unfortunately, the plugin apparently does not sort correctly by that difference. In my case, a team with a difference of -18 was ranked higher than on with a difference of -12.
In the volleyball.php Line 71 there is the sort sequence:
function rankTeams( $teams ) { foreach ( $teams AS $key => $row ) { $points[$key] = $row->points['plus']+$row->add_points; $set_diff[$key] = $row->sets['plus']-$row->sets['minus']; $won_sets[$key] = $row->sets['plus']; $ballpoints_diff[$key] = $row->ballpoints['plus']-$row->ballpoints['minus']; $ballpoints[$key] = $row->ballpoints['plus']; }
followed by the multisort command:
array_multisort( $points, SORT_DESC, $set_diff, SORT_DESC, $won_sets, SORT_DESC, $ballpoints_diff, SORT_DESC, $ballpoints, SORT_DESC, $teams ); return $teams; }
The reason why this fails (if I am not mistaken), is because sets doesnt know the parameters ‘plus’ and ‘minus’ (line 75 and 76) like ‘points’ and ‘ballpoints’ do, instead you have to use ‘won’ and ‘lost’ here. So you have to change both lines 75 and 76:
$set_diff[$key] = $row->sets['plus']-$row->sets['minus']; $won_sets[$key] = $row->sets['plus'];
in
$set_diff[$key] = $row->sets['won']-$row->sets['lost']; $won_sets[$key] = $row->sets['won'];
It did the trick for me…
- The topic ‘Bug in sorting of standings in volleyball’ is closed to new replies.