Return to Snippet

Revision: 55560
at February 11, 2012 06:17 by bitsculptor

Initial Code
$transactions = array(
0 => array('date'=>1324235252, 'day'=>'monday'),
1 => array('date'=>1326516552, 'day'=>'tuesday'),
2 => array('date'=>1333453235, 'day'=>'wednesday')

function sortByOrder($a, $b) {
    return $b['date'] - $a['date'];

usort($transactions, 'sortByOrder');

Initial URL

Initial Description
This sorts a multi-dimensional array by one of the values in the array. Sorts in Desc order (most recent date first).

Initial Title
Sort multidimensional array

Initial Tags
php, sort, array

Initial Language