Re: ksort feature ???
| From: | Ryan Adams | Date: | Tue, 13 Jun 2000 13:58:31 +0000 |
| Subject: | Re: ksort feature ??? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-1713@lists.php.net to get a copy of this message | ||
Hello,
Since PHP uses overloaded variable types and associative arrays, is it possible
that it is interpreting the float keys as strings? In that case it might be possible
to use uksort...
i.e.
function floatkey ($a, $b) {
settype ($a, "double");
settype ($b, "double");
if ($a == $b)
return 0;
return ($a > $b) ? -1:1;
}
uksort ($myarray, floatkey);
hth,
Ryan
On Mon, Jun 12, 2000 at 03:32:18PM -0700, Mikhail Avrekh wrote:
> Hello,
>
> I wonder if the following is a bug or a feature in PHP3:
>
> I create a hash with float (%.1f) numbers for the keys; when I sort it
> with ksort, it appears that 2.0 is greater than 19.0,
> i.e. $aryelement[2.0] comes out after $aryelement[19.0]
>
> ???????????
>
> Thanks !
>
> Mikhail
>