Re: Sorting Bug / Wrong behavior?
| From: | Stefan Walk | Date: | Tue, 27 Jul 2004 20:08:47 +0000 |
| Subject: | Re: Sorting Bug / Wrong behavior? | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-11586@lists.php.net to get a copy of this message | ||
On Tue, Jul 27, 2004 at 02:48:28PM -0500, John Coggeshall wrote:
> Notice how 0 and c are switched incorrectly. Attached is a patch to
> zend_operators.c that fixes it.
The Manual says:
> Warning
>
> Be carefull when sorting arrays with mixed types values because sort()
> can produce unpredictable results.
You could use SORT_STRING, natsort, etc...
If this gets "fixed", the $a = "0d9"; var_dump(++$a, ++$a); thing could
also be "fixed", as its WTF factor is as high... or "010" == "1e1"
being
true. It's all the consequence of PHPs handling with numbers and
strings, which can produce results that strike you as odd.