Re: Re: PHP 4.0 Bug #5730 Updated: sort and rsort are not 'opposites'
| From: | jalal | Date: | Sun, 23 Jul 2000 11:32:20 +0000 |
| Subject: | Re: Re: PHP 4.0 Bug #5730 Updated: sort and rsort are not 'opposites' | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-25562@lists.php.net to get a copy of this message | ||
On Sun, 23 Jul 2000 13:50:01 +0300 (IDT), Stanislav Malyshev wrote:
>j>> Hmm, well thats not the case over here... default sort is 'random'.
>
>What do you mean by 'random'? I fear you lost me here.
>
Well, thats probably not the clearest definition I could have given ;-}
Example:
$a = array("0", "1", "01", "02", "2");
sort($a);
gives
0 01 1 2 02
this seems to be neither string or numeric, although I guess you could
ague that it is numeric.
$a = array("0", "1", "01", "02", "2");
rsort($a);
gives
02 2 01 1 0
this is numeric I would say....
But in the first example, the rules for sorting don't seem to be clear
from looking at the result, which is why I called it random.
However, I would expect the results from sort and rsort to be
symmetric... which they aren't.
Using SORT_STRING in the above two examples gives:
0 01 02 1 2
2 1 02 01 0
which is clearly string sorting.
-- jalal --