php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #18050 asort not sorting properly
Submitted: 2002-06-28 14:28 UTC Modified: 2002-08-20 19:34 UTC
From: bstoppel at ku dot edu Assigned:
Status: Closed Package: Arrays related
PHP Version: 4.2.1 OS: Digital UNIX V4.0F (Rev. 1229)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: bstoppel at ku dot edu
New email:
PHP Version: OS:

 

 [2002-06-28 14:28 UTC] bstoppel at ku dot edu
I used the example given in the asort documentation. The result is not correct. Here is the example for your convenience:

$fruits = array ("d"=>"lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple");
asort ($fruits);
reset ($fruits);
while (list ($key, $val) = each ($fruits)) {
    echo "$key = $val\n";
}

The actual output is 
d = lemon
a = orange
b = banana
c = apple

The expected output is
c = apple
b = banana
d = lemon
a = orange



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-06-28 14:37 UTC] rasmus@php.net
Hrm..  On my Linux box your script outputs:

c = apple
b = banana
d = lemon
a = orange

Are you on a 64-bit platform?  I'm looking at the zend_qsort() function but I don't see an obvious mistake.
 [2002-06-28 15:05 UTC] bstoppel at ku dot edu
The platform that I am using is 64-bit.

BTW - before upgrading to 4.21, we were using 4.06 and the sort function worked fine.
 [2002-06-28 15:15 UTC] mfischer@php.net
Sterling mentioned something about a cast fix in zend_qsort, please try http://snaps.php.net/php4-latest.tar.gz
 [2002-08-20 16:52 UTC] long at ku dot edu
I'm the person responsible for PHP on bstoppel's system.  I've just built php4-200208201200 and it looks like asort() is working properly again.  However, I'm seeing this message when running php:

Unaligned access pid=26595 <php> va=0x1400b701c pc=0x12025d930 ra=0x12025d040 inst=0xb4010000

which indicates an unaligned memory access.  I couldn't build zend_API.c without adding an #include "php.h" to get the macro re-definition of snprintf() but I was told that could be a "bad" thing to do so perhaps that is causing the unaligned memory accesses...
 [2002-08-20 19:34 UTC] nohn@php.net
Duplicate to bug #17449. This bug is already closed in current CVS. 4.3.0 will work, I hope 4.2.3 will work too.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 19 13:01:33 2024 UTC