Skip to content

Instantly share code, notes, and snippets.

@GiovanniK
Created August 18, 2014 07:56
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 GiovanniK/de0fdf9b08fcdd0b9f10 to your computer and use it in GitHub Desktop.
Save GiovanniK/de0fdf9b08fcdd0b9f10 to your computer and use it in GitHub Desktop.
Sort array (descending or ascending)
public static function do_sort($a, $b) {
$date = $a->publishOn;
$date2 = $b->publishOn;
$aval = strtotime($date);
$bval = strtotime($date2);
if ($aval == $bval) {
return 0;
}
return $aval > $bval ? -1 : 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment