From:             [EMAIL PROTECTED]
Operating system: Digital UNIX V4.0G (Rev. 1530)
PHP version:      4.2.0
PHP Bug Type:     Unknown/Other Function
Bug description:  sort() does not work

Example script:

<?php 
function cmp ($x, $y){
  $c = (int) $x;
  $d = (int) $y;

  if($c == $d) return 0;
  return ($c > $d) ? 1 : -1;
}

$arr = array(1, 3, 2, 10, 9);
//print_r($arr);
var_dump($arr);
sort($arr, SORT_NUMERIC);
var_dump($arr);
//reset($arr);
echo "<br><br>";
print_r($arr);
/*srand((float)microtime()*1000000);
shuffle($arr);
echo "<br><br>";
print_r($arr);*/
?>

########################################################
PHP Version 4.0.6

SunOS xxxxxxx 5.7 Generic_106541-15 sun4us sparc FJSV,GPUS

'./configure' '--prefix=/usr/local'
'--with-apache=/usr/local/Apachetoolbox-1.5.34/apache_1.3.20'
'--enable-exif' '--enable-track-vars' '--with-calendar=shared'
'--enable-safe-mode' '--enable-magic-quotes' '--enable-trans-sid'
'--enable-wddx' '--enable-ftp' '--with-oci8'
'--with-mysql=/usr/local/mysql' 
########################################################

array(5) {
  [0]=>
  int(1)
  [1]=>
  int(3)
  [2]=>
  int(2)
  [3]=>
  int(10)
  [4]=>
  int(9)
}
array(5) {
  [0]=>
  int(1)
  [1]=>
  int(2)
  [2]=>
  int(3)
  [3]=>
  int(9)
  [4]=>
  int(10)
}
Array
(
    [0] => 1
    [1] => 2
    [2] => 3
    [3] => 9
    [4] => 10
)

So sorting works fine on PHP 4.0.6 on Solaris

########################################################
PHP Version 4.2.0

OSF1 xxxxx V4.0 1530 alpha

'./configure' '--prefix=/usr/local'
'--with-apache=/usr/local/Apachetoolbox-1.5.56/apache_1.3.24'
'--enable-exif' '--enable-track-vars' '--with-calendar=shared'
'--enable-safe-mode' '--enable-magic-quotes' '--enable-trans-sid'
'--enable-wddx' '--enable-ftp' '--with-openssl=/usr/local'
'--with-oci8=/appl/oracle/product/8.1.6' '--with-mysql=/usr/local/mysql'
########################################################


array(5) {
  [0]=>
  int(1)
  [1]=>
  int(3)
  [2]=>
  int(2)
  [3]=>
  int(10)
  [4]=>
  int(9)
}
array(5) {
  [0]=>
  int(1)
  [1]=>
  int(3)
  [2]=>
  int(2)
  [3]=>
  int(10)
  [4]=>
  int(9)
}
Array
(
    [0] => 1
    [1] => 3
    [2] => 2
    [3] => 10
    [4] => 9
)
-- 
Edit bug report at http://bugs.php.net/?id=17449&edit=1
-- 
Fixed in CVS:        http://bugs.php.net/fix.php?id=17449&r=fixedcvs
Fixed in release:    http://bugs.php.net/fix.php?id=17449&r=alreadyfixed
Need backtrace:      http://bugs.php.net/fix.php?id=17449&r=needtrace
Try newer version:   http://bugs.php.net/fix.php?id=17449&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=17449&r=support
Expected behavior:   http://bugs.php.net/fix.php?id=17449&r=notwrong
Not enough info:     http://bugs.php.net/fix.php?id=17449&r=notenoughinfo
Submitted twice:     http://bugs.php.net/fix.php?id=17449&r=submittedtwice
register_globals:    http://bugs.php.net/fix.php?id=17449&r=globals

Reply via email to