function array_sort($arr,$keys,$type='asc') { $keysvalue = $new_array = array(); foreach ($arr as $k => $v) { $keysvalue[$k] = $v[$keys]; } if ($type == 'asc') { //对数组进行排序并保持索引关系 asort($keysvalue); } else { //对数组进行逆向排序并保持索引关系 arsort($keysvalue); } reset($keysvalue); foreach ($keysvalue as $k => $v) { $new_array[] = $arr[$k]; } return $new_array; }