Created
January 30, 2016 06:27
-
-
Save kyptov/c9939485aad117a69ea0 to your computer and use it in GitHub Desktop.
A simple way to sort data from database. Useful when cannot be use ORDER BY
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 | |
$array = [ | |
['ts' => 3], | |
['ts' => 5], | |
['ts' => 1], | |
['ts' => 2], | |
['ts' => 7], | |
['ts' => 0], | |
]; | |
usort($array, function($a, $b) { | |
return $a['ts'] - $b['ts']; | |
}); | |
var_dump($array); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment