note 97047 deleted from array.sorting by salathe
| From: | salathe@php.net | Date: | Tue, 02 Aug 2016 12:07:45 +0000 |
| Subject: | note 97047 deleted from array.sorting by salathe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-206172@lists.php.net to get a copy of this message | ||
Note Submitter: Dirk
----
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...