-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
League table custom sort issue with decimal values #427
Labels
Comments
Or maybe even the simpler version |
@rochesterj is that issue still there? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In the sportspress/includes/class-sp-league-table.php file, lines 911 and 917, uasort expects 0 or 1 or -1, thus simply returning the value difference will give inconsistent results.
How to reproduce:
Create a new league table, use a column with decimal places then add a difference smaller than 1 between items:
e.g
Team A: 5.28
Team B: 6.27
The ordering will be broken, because the function returns -0.99 instead of -1.
How to fix it:
A simple one line conditional statement should do it:
return ( (float) $b[ $this->orderby ] - (float) $a[ $this->orderby ] ) > 0 ? 1 : -1;
and
return ( (float) $a[ $this->orderby ] - (float) $b[ $this->orderby ] ) > 0 ? 1 : -1;
At least this fixes the issue for me. Cheers!
The text was updated successfully, but these errors were encountered: