From:             
Operating system: Debian
PHP version:      5.3.4
Package:          Arrays related
Bug Type:         Bug
Bug description:Same value items reverted in asort() and arsort()

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 bug report at http://bugs.php.net/bug.php?id=53553&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=53553&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=53553&r=trysnapshot53
Try a snapshot (trunk):              
http://bugs.php.net/fix.php?id=53553&r=trysnapshottrunk
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=53553&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=53553&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=53553&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=53553&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=53553&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=53553&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=53553&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=53553&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=53553&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=53553&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=53553&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=53553&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=53553&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=53553&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=53553&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=53553&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=53553&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=53553&r=mysqlcfg

Reply via email to