function sort_array($array, $keyid, $order='asc', $type='number') { if(is_array($array)) { foreach($array as $val) { $order_arr[] = $val[$keyid]; } $order = ($order == 'asc') ? sort_asc: sort_desc; $type = ($type == 'number') ? sort_numeric: sort_string; array_multisort($order_arr, $order, $type, $array); } }