### 希爾排序算法偽代碼
```
// 希爾排序
function shellSort(&$array)
{
$count_array = count($array);
for($i = (int)($count_array/2);$i>0;$i=(int)($i/2)){ //循環分隔整個數組為多個長度為增量(增量為整數,每次循環除以2)的子序列
for($j = (int)$i;$j<$count_array;$j++){ //從增量開始判斷
$index = (int)($j - $i); //步長為增量
$current = $array[$j];
while($index >= 0 && $array[$index] > $current){ //相對選擇排序只是步長為增量而不為1
$array[$index + $i] = $array[$index];
$index = $index - $i;
}
$array[$index + $i] = $current;
}
}
// return $array;
}
$array = array(3,1,5,6,35,63,23,4,7,2,65);
shellSort($array);
print_r($array);
```
打印結果:
```
Array
(
[0] => 1
[1] => 2
[2] => 3
[3] => 4
[4] => 5
[5] => 6
[6] => 7
[7] => 23
[8] => 35
[9] => 63
[10] => 65
)
```