From:             tuxedobob at mac dot com
Operating system: Mac OS X 10.2.6
PHP version:      4.3.2
PHP Bug Type:     Feature/Change Request
Bug description:  Bring back unchanging usort() values if equal

The script:

<?php

function comp($a, $b) {
  if (ceil($a) < ceil($b)) return (-1);
  if (ceil($a) > ceil($b)) return (1);
  return 0;
}

$arr = array('5.2', '5.4', '5.5', '5.9');

for ($x = 0; $x < 10; $x++) {
usort($arr, "comp");
print_r($arr);
}

?>

(Any useful function can also be used for comp.)

When running the above script, usort() reverses the 
array upon each iteration. The documentation says as 
much might happen. However, it's much more useful if it 
doesn't. Perhaps there can be a new function so usort() 
can work the way it did in PHP<=4.0.6 for when the 
speed penalty is not an issue?
-- 
Edit bug report at http://bugs.php.net/?id=24004&edit=1
-- 
Try a CVS snapshot:         http://bugs.php.net/fix.php?id=24004&r=trysnapshot
Fixed in CVS:               http://bugs.php.net/fix.php?id=24004&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=24004&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=24004&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=24004&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=24004&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=24004&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=24004&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=24004&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=24004&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=24004&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=24004&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=24004&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=24004&r=gnused

Reply via email to