[php-src] Issue #10900: Wrong array sorting with NAN

From: Date: Tue, 21 Mar 2023 11:31:23 +0000
Subject: [php-src] Issue #10900: Wrong array sorting with NAN
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-243954@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/10900 Author: KapitanOczywisty ### Description NAN can break sorting of other elements, probably due to comparison with NAN always returning 1. ``` echo 1 <=> NAN, NAN <=> 1, NAN <=> NAN; // 111 ``` The following code: ```php <?php $a = [ 1.2, NAN, 3.2, 2.4, ]; rsort($a); print_r($a); ``` Resulted in this output: ``` Array ( [0] => 1.2 [1] => NAN [2] => 3.2 [3] => 2.4 ) ``` But I expected this output instead: ``` Array ( [0] => 3.2 [1] => 2.4 [2] => 1.2 [3] => NAN ) ``` https://3v4l.org/fpR4G ### PHP Version 8.* ### Operating System _No response_

« previous php.bugs (#243954) next »