Welcome Guest, Not a member yet? Register   Sign In
Multidimensional array sort by date
#6

[eluser]pickupman[/eluser]
@jprateragg has the best of doing it in the model, provided that a UNION will work. Otherwise you can use [url="http://php.net/manual/en/function.usort.php"]ursort()[/url]. Here's a quick comparison function that will work on your array.
Code:
function sort_by_date($a, $b)
{
if ($a->added_date == $b->added_date)
{
  return 0;
}

return ($a->added_date < $b->added_date) ? -1 : 1;
}

usort($yourData, 'sort_by_date');


Messages In This Thread
Multidimensional array sort by date - by El Forum - 12-10-2012, 10:46 AM
Multidimensional array sort by date - by El Forum - 12-10-2012, 11:00 AM
Multidimensional array sort by date - by El Forum - 12-10-2012, 02:41 PM
Multidimensional array sort by date - by El Forum - 12-10-2012, 07:24 PM
Multidimensional array sort by date - by El Forum - 12-11-2012, 09:35 AM
Multidimensional array sort by date - by El Forum - 12-11-2012, 12:16 PM



Theme © iAndrew 2016 - Forum software by © MyBB