Re: [PHP4BETA] rsort() bug?

From: Date: Wed, 10 May 2000 18:29:59 +0000
Subject: Re: [PHP4BETA] rsort() bug?
References: 1 2  Groups: php.version4 
Request: Send a blank email to php-version4+get-14774@lists.php.net to get a copy of this message
On Wed, 10 May 2000, Sascha Schumann wrote: > Solaris' qsort does not like that. We cannot change > compare_function, because that would break thousands of scripts. > rsort() should not use qsort. Then we have a problem. I changed rsort() to use mergesort() and ran this example through it. <? $ar1 = array("100", 10, "10", "9", "abc"); rsort($ar1); ?> The results were: array(5) { [0]=> string(3) "100" [1]=> int(10) [2]=> string(3) "abc" [3]=> string(2) "10" [4]=> string(1) "9" } Which is clearly not correct. We seem to be between a rock and a hard place - qsort() crashes and mergesort() doesn't produce valid results. All because compare_function() is non-deterministic. -Andrei * If it's never finished, you can't prove it doesn't work. *

« previous php.version4 (#14774) next »