Created
September 1, 2015 14:52
-
-
Save alanszlosek/5c1a6e053762ed6bfa9e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
error_reporting(E_ALL); | |
$a = new stdClass(); | |
$a->name = 'Zzzz'; | |
$b = new stdClass(); | |
$b->name = 'Bbbb'; | |
$meets = array(); | |
$meets[] = $a; | |
$meets[] = $b; | |
$names = array(); | |
$names[] = $a->name; | |
$names[] = $b->name; | |
// We'll get PHP Notices about attempting to convert each meet object to a number | |
array_multisort($meets, SORT_NUMERIC, SORT_DESC, $names, SORT_STRING, SORT_ASC); | |
var_dump($meets); | |
echo "NEXT\n\n"; | |
// Sort the other direction ... No notices when used correctly | |
array_multisort($names, SORT_STRING, SORT_DESC, $meets); | |
var_dump($meets); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output: