I have this array :
$order_list = array ( array ("tangible", 1, 8, 1, 19000),
array ("tangible", 6, 2, 10, NULL),
array ("tangible", 1, 17, 1, 28000));
and I have this code to sort it :
usort($order_list, function ($a, $b) {
if ($a[1] == $b[1]) return 0;
return (int) $a[1] < (int) $b[1] ? -1 : 1;
});
the problem is, it only sort $order_list[$i][1]
ascending. it will produce this result :
array ("tangible", 1, 8, 1, 19000)
array ("tangible", 1, 17, 1, 28000)
while I need $order_list[$i][2]
also to be sorted, but descending. so it will produce :
array ("tangible", 1, 17, 1, 28000)
array ("tangible", 1, 8, 1, 19000)
array ("tangible", 6, 2, 10, NULL)
how to sort an array based on 2 keys like this? thanks before.