note 97047 added to array.sorting

From: Date: Mon, 29 Mar 2010 21:32:56 +0000
Subject: note 97047 added to array.sorting
Groups: php.notes 
Request: Send a blank email to php-notes+get-167513@lists.php.net to get a copy of this message
If you need to perform any of these sort functions on an array containing two or more equivalent values, you can get the equivalents to fall next to each other within the overall ordering (similar to how MySQL's ORDER BY works...) instead of breaking the sort() function, by using ksort() as a second parameter to arbitrarily distinguish any equivalent values by their unique keys: <?php sort($array, ksort($array)); ?> Seems like this effect should be built in. At least the workaround is so short... ---- Server IP: 69.147.83.197 Probable Submitter: 66.213.33.136 ---- Manual Page -- http://www.php.net/manual/en/array.sorting.php Edit -- https://master.php.net/note/edit/97047 Del: integrated -- https://master.php.net/note/delete/97047/integrated Del: useless -- https://master.php.net/note/delete/97047/useless Del: bad code -- https://master.php.net/note/delete/97047/bad+code Del: spam -- https://master.php.net/note/delete/97047/spam Del: non-english -- https://master.php.net/note/delete/97047/non-english Del: in docs -- https://master.php.net/note/delete/97047/in+docs Del: other reasons-- https://master.php.net/note/delete/97047 Reject -- https://master.php.net/note/reject/97047 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#167513) next »