I took a look at the user submited array_qsort2 function, and there is a far easier method of doing the same thing using the usort function. Here is an example for you to try:
function usort_descending($array1, $array2)
{
if($array1["b"] == $array2["b"])
return 0;
elseif($array1["b"] > $array2["b"])
return -1;
else
return 1;
}
function usort_ascending($array1, $array2)
{
if($array1["b"] == $array2["b"])
return 0;
elseif($array1["b"] > $array2["b"])
return 1;
else
return -1;
}
$new[0] = array('a'=>5, 'b'=>3, 'c'=>7) ;
$new[1] = array('a'=>5, 'b'=>6, 'c'=>7) ;
$new[2] = array('a'=>5, 'b'=>1, 'c'=>7) ;
usort($new, "usort_descending"); // Sorts by $new[][b] descending
usort($new,"usort_ascending"); // Sorts by $new[][b] ascending
Give it a try... smaller, easier to understand code is always best 🙂