From 25461004fdaff94f6b06e1b1acd6999c2fa8186d Mon Sep 17 00:00:00 2001 From: MichiMensing Date: Sat, 10 May 2025 23:35:18 -0400 Subject: [PATCH] fix: custom sort with decimals Resolves #427 --- includes/class-sp-league-table.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/class-sp-league-table.php b/includes/class-sp-league-table.php index 9b3f9673..405104f9 100644 --- a/includes/class-sp-league-table.php +++ b/includes/class-sp-league-table.php @@ -908,13 +908,13 @@ public function simple_order( $a, $b ) { if ( $this->orderby == 'name' ) { return strcmp( sp_array_value( $b, 'name', '' ), sp_array_value( $a, 'name', '' ) ); } else { - return (float) $b[ $this->orderby ] - (float) $a[ $this->orderby ]; + return ( (float) $b[ $this->orderby ] - (float) $a[ $this->orderby ] ) > 0 ? 1 : -1; } } else { if ( $this->orderby == 'name' ) { return strcmp( sp_array_value( $a, 'name', '' ), sp_array_value( $b, 'name', '' ) ); } else { - return (float) $a[ $this->orderby ] - (float) $b[ $this->orderby ]; + return ( (float) $a[ $this->orderby ] - (float) $b[ $this->orderby ] ) > 0 ? 1 : -1; } } }