I have this array of arrays
foreach($qcatResults as $qcatResult){
...//codes to get stuff
$cats[] = array(
'category_code' => $qcatResult->category_code,
'category' => $qcatResult->category,
'item_count' => $item_count,
'max_qty' => (int)$max_qty
);
}
var_dump($cats);
which would result to something like
array(34) {
[0]=> array(4) { ["category_code"]=> string(2) "BB" ["category"]=> string(0) ""
["item_count"]=> string(1) "1" ["max_qty"]=> int(12000) }
[1]=> array(4) { ["category_code"]=> string(2) "AK" ["category"]=> string(6) "Anklet"
["item_count"]=> string(1) "1" ["max_qty"]=> int(6) }
[2]=> array(4) { ["category_code"]=> string(3) "BAC" ["category"]=> string(15) "Bag Accessories"
["item_count"]=> string(1) "2" ["max_qty"]=> int(352) }
[3]=> array(4) { ["category_code"]=> string(2) "WB" ["category"]=> string(4) "Bags"
["item_count"]=> string(1) "9" ["max_qty"]=> int(6290) }
[4]=> array(4) { ["category_code"]=> string(2) "AB" ["category"]=> string(20) "Bathroom Accessories"
["item_count"]=> string(2) "19" ["max_qty"]=> int(325) }
[5]=> array(4) { ["category_code"]=> string(2) "BK" ["category"]=> string(4) "Book"
["item_count"]=> string(2) "40" ["max_qty"]=>int(27291) }...
}
I want to sort $cats by max_qty in descending order, but array_multisort is giving out the error Message: array_multisort(): Argument #1 is expected to be an array or a sort flag
I have this usage of array_multisort():
var_dump(array_multisort($max_qty, SORT_DESC, $cats));