Bug #69330 [NEW]: SORT_* DOSNT WORK in array_multisort

From: Date: Mon, 30 Mar 2015 07:59:09 +0000
Subject: Bug #69330 [NEW]: SORT_* DOSNT WORK in array_multisort
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-191708@lists.php.net to get a copy of this message
From: to dot yashin at gmail dot com Operating system: ubuntu PHP version: 5.5.23 Package: Scripting Engine problem Bug Type: Bug Bug description:SORT_* DOSNT WORK in array_multisort Description: ------------ The second optional parameter array1_sort_order=SORT_DESC in array_multisort function does not work Test script: --------------- <?php $result = array( array( 'position' => 1, 'col1' => 10, 'col2' => 10, ), array( 'position' => 2, 'col1' => 12, 'col2' => 10, ), array( 'position' => 3, 'col1' => 10, 'col2' => 11, ), ); $col1_data = array(); $col2_data = array(); foreach ($result as $key => $row) { $col1_data[] = intval($row['col1']); $col2_data[] = intval($row['col2']); } // SORT_DESC ! array_multisort($result, SORT_DESC, SORT_NUMERIC, $col1_data, $col2_data); foreach ($result as $row) { echo $row['position'], ' '; } echo "\n"; // Actual: 1 3 2 // Expected: 2 3 1 Expected result: ---------------- Sort Descending correct: 2 3 1 Actual result: -------------- Sort Descending is not correct: 1 3 2 -- Edit bug report at https://bugs.php.net/bug.php?id=69330&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69330&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69330&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69330&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=69330&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=69330&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=69330&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=69330&r=needscript Try newer version: https://bugs.php.net/fix.php?id=69330&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=69330&r=support Expected behavior: https://bugs.php.net/fix.php?id=69330&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=69330&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=69330&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=69330&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69330&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=69330&r=dst IIS Stability: https://bugs.php.net/fix.php?id=69330&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=69330&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=69330&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=69330&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=69330&r=mysqlcfg

« previous php.bugs (#191708) next »