Re: [PHP4BETA] rsort() bug?
| From: | Sascha Schumann | Date: | Wed, 10 May 2000 17:10:05 +0000 |
| Subject: | Re: [PHP4BETA] rsort() bug? | ||
| References: | 1 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-14766@lists.php.net to get a copy of this message | ||
On Wed, 10 May 2000, Andrei Zmievski wrote:
> Can anyone confirm this crash?
>
> <?
> $ar1 = array("100", 10, "10", "9", "abc");
> rsort($ar1);
> ?>
>
> This is on Solaris, btw.
The problem is the behaviour of compare_function.
For "100" and 10, it says "100" > 10
For "100" and "abc", it says "100" < abc
For "abc" and "10", it says "abc" < 10
This is correct, if you look at each decision. But that leads to:
100 < abc < 10
and
10 < 100
Solaris' qsort does not like that. We cannot change
compare_function, because that would break thousands of scripts.
rsort() should not use qsort.
- Sascha