|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2015-03-30 08:16 UTC] to dot yashin at gmail dot com
-Summary: SORT_* DOSNT WORK in array_multisort
+Summary: SORT_* DOESN'T WORK in array_multisort
[2015-03-30 08:16 UTC] to dot yashin at gmail dot com
[2015-03-30 08:51 UTC] requinix@php.net
-Status: Open
+Status: Not a bug
[2015-03-30 08:51 UTC] requinix@php.net
[2015-03-30 08:56 UTC] to dot yashin at gmail dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 07 14:00:01 2026 UTC |
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