Skip to content

Instantly share code, notes, and snippets.

@kyptov
Created January 30, 2016 06:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kyptov/c9939485aad117a69ea0 to your computer and use it in GitHub Desktop.
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
<?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