Edit report at http://bugs.php.net/bug.php?id=53553&edit=1

 ID:                 53553
 Updated by:         [email protected]
 Reported by:        clau dot cristea at gmail dot com
 Summary:            Same value items reverted in asort() and arsort()
-Status:             Open
+Status:             Bogus
 Type:               Bug
 Package:            Arrays related
 Operating System:   Debian
 PHP Version:        5.3.4
 Block user comment: N
 Private report:     N

 New Comment:

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

Then I don't know where you got the idea the sorting of asort() and
arsort() was stable.



Closing as bogus. See also bug #53341.


Previous Comments:
------------------------------------------------------------------------
[2010-12-16 13:26:50] clau dot cristea at gmail dot com

> Where is it stated in the docs the sort is stable?



Don't know... Where is stated that is not?

------------------------------------------------------------------------
[2010-12-16 11:52:27] [email protected]

Where is it stated in the docs the sort is stable?

------------------------------------------------------------------------
[2010-12-16 11:10:39] clau dot cristea at gmail dot com

Description:
------------
After sorting an associative array with asort() or arsort() items having
same value are reverted.



Those sorting must preserve order on same value case.



---

>From manual page: http://www.php.net/function.arsort

---



Test script:
---------------
<?php



$a = array('first' => 2, 'second' => 2);

$b = $a; // Save original.



print "Original:\n";

print_r($a);



asort($a);



print "\n\nasort():\n";

print_r($a);



arsort($b);



print "\n\narsort():\n";

print_r($b);

print "\n";



?>



Expected result:
----------------
I'm expecting that asort() and arsort() to preserve the order of items
having the same value.

Actual result:
--------------
See below asort(); and arsort(); that keys were reverted.


------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=53553&edit=1

Reply via email to