Created
May 25, 2017 06:40
-
-
Save SBaof/b3c7d90d43347c0ed87c5f51c84126f4 to your computer and use it in GitHub Desktop.
PHP: 二维数组排序
This file contains 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
待排数组: | |
``` | |
$user = [ | |
[ | |
'name' => 'tom', | |
'age' => 10, | |
], | |
[ | |
'name' => 'Jim', | |
'age' => 9, | |
], | |
[ | |
'name' => 'Janne', | |
'age' => 18, | |
] | |
] | |
``` | |
usort ($user, function($a, $b) { | |
return $a.age - $b.age; | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment