Skip to content

Instantly share code, notes, and snippets.

@alganet
Forked from filaruina/gist:645373
Created October 25, 2010 19:57
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 alganet/645616 to your computer and use it in GitHub Desktop.
Save alganet/645616 to your computer and use it in GitHub Desktop.
<?php
$teste = array(
array("foo" => "a", "bar" => "b", "timestamp" => 123456),
array("foo" => "a", "bar" => "b", "timestamp" => 987654),
array("foo" => "a", "bar" => "b", "timestamp" => 654789),
array("foo" => "a", "bar" => "b", "timestamp" => 456123)
);
function sortTimestamp($a, $b) {
return $a['timestamp'] > $b['timestamp'] ? 1 : -1;
}
usort($teste, 'sortTimestamp');
print_r($teste);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment