|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2011-01-02 02:12 UTC] jani@php.net
-Status: Open
+Status: Wont fix
-Package: Feature/Change Request
+Package: *General Issues
[2011-01-02 02:12 UTC] jani@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 11:00:02 2025 UTC |
Description: ------------ $ar = array(array("10", 100, 100, "a"), array(1, 3, "2", 1)); we now must do: array_multisort($ar[0], SORT_ASC, SORT_STRING, $ar[1], SORT_NUMERIC, SORT_DESC); 1. ======== how about: array_multisort($ar, "0", SORT_ASC, SORT_STRING, "1", SORT_NUMERIC, SORT_DESC); but "int" type of key may mixed with sort flags :( nicer example: $ar = array('abc' => array("10", 100, 100, "a"), 'def' => array(1, 3, "2", 1)); array_multisort($ar, "abc", SORT_ASC, SORT_STRING, "def", SORT_NUMERIC, SORT_DESC); this is VERY useful when you have so many arrays in $ar, but only want to sort BY some of it 2. ======== because "SHOW PROCESSLIST" cannot do a "ORDER BY" we need: /* $rows = array(); while ($row = mysqli_fetch_assoc()) { $rows[] = $row; } */ $rows = array( array('a' => "10", 'b' => 100, 'c' => 100, 'd' => "a"), array('a' => 1, 'a' => 3, 'a' => "2", 'd' => 1) ); array_multisort_rows($row, "a", SORT_ASC, SORT_STRING, "b", SORT_NUMERIC, SORT_DESC);