Incorrect Standings Positions
-
Standings positions are not always calculated correctly because uasort doesn’t always compare array elements in the order that class-sp-league-table.php assumes.
I have a four team competition with clear 1st & 4th place teams and the other two teams are tied for 2nd place. SportsPress shows the standings positions as [1,2,3,3] when they should be [1,2,2,4].
Rather than using uasort with calculate_pos, just iterate through the sorted array, comparing consecutive elements, somewhat like this quick fix (warning: bugs may still exist):
$a = array_shift ($temp); if ($a) while ($b = array_shift ($temp)) { $this->counter++; // Loop through priorities foreach( $this->priorities as $priority ): // Proceed if columns are not equal if ( sp_array_value( $a, $priority['column'], 0 ) != sp_array_value( $b, $priority['column'], 0 ) ): // Increment if not equal $this->pos[] = $this->counter; $a = $b; continue 2; endif; endforeach; // Repeat position if equal $this->pos[] = end( $this->pos ); $a = $b; }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘Incorrect Standings Positions’ is closed to new replies.