/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// convert associative array to 2d array function arr_convert_2d($arr) { foreach ($arr as $k => $v) { } return $tmp_arr; } // convert 2d associative array to 1d array function arr_convert_1d($arr) { foreach ($arr as $v) { $tmp_arr[$v['index']] = $v['value']; } return $tmp_arr; } function assoc_quicksort($arr) { $pivot = $arr[0]; if($arr[$i]['value'] <= $pivot['value']) { $left[] = $arr[$i]; } else { $right[] = $arr[$i]; } } } $qsort_assoc_arr = arr_convert_1d(assoc_quicksort(arr_convert_2d($changed_arr)));