<?php
function quicksort($array) {
if (count($array) <= 1) {
return $array;
}
$pivot = array_shift($array); // ピボットの選択
$left = $right = array();
foreach ($array as $value) {
if ($value < $pivot) {
$left[] = $value;
} else {
$right[] = $value;
}
}
// 左右のデータを再帰的にソートする
return array_merge(quicksort($left), array($pivot), quicksort($right));
}
$array = array(
6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,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 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,6, 4, 3, 7, 8, 5, 2, 9, 1,
);
$array = quicksort($array);
var_dump($array); // 1, 2, 3, 4, 5, 6, 7, 8, 9
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename: /in/aSBL4
function name: (null)
number of ops: 9
compiled vars: !0 = $array
line #* E I O op fetch ext return operands
-------------------------------------------------------------------------------------
22 0 E > ASSIGN !0, <array>
25 1 INIT_FCALL 'quicksort'
2 SEND_VAR !0
3 DO_FCALL 0 $2
4 ASSIGN !0, $2
26 5 INIT_FCALL 'var_dump'
6 SEND_VAR !0
7 DO_ICALL
8 > RETURN 1
Function quicksort:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 5
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 21
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 21
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 18
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
filename: /in/aSBL4
function name: quicksort
number of ops: 36
compiled vars: !0 = $array, !1 = $pivot, !2 = $left, !3 = $right, !4 = $value
line #* E I O op fetch ext return operands
-------------------------------------------------------------------------------------
3 0 E > RECV !0
4 1 COUNT ~5 !0
2 IS_SMALLER_OR_EQUAL ~5, 1
3 > JMPZ ~6, ->5
5 4 > > RETURN !0
7 5 > INIT_FCALL 'array_shift'
6 SEND_REF !0
7 DO_ICALL $7
8 ASSIGN !1, $7
9 9 ASSIGN ~9 !3, <array>
10 ASSIGN !2, ~9
10 11 > FE_RESET_R $11 !0, ->21
12 > > FE_FETCH_R $11, !4, ->21
11 13 > IS_SMALLER !4, !1
14 > JMPZ ~12, ->18
12 15 > ASSIGN_DIM !2
16 OP_DATA !4
17 > JMP ->20
14 18 > ASSIGN_DIM !3
19 OP_DATA !4
10 20 > > JMP ->12
21 > FE_FREE $11
18 22 INIT_FCALL 'array_merge'
23 INIT_FCALL_BY_NAME 'quicksort'
24 SEND_VAR_EX !2
25 DO_FCALL 0 $15
26 SEND_VAR $15
27 INIT_ARRAY ~16 !1
28 SEND_VAL ~16
29 INIT_FCALL_BY_NAME 'quicksort'
30 SEND_VAR_EX !3
31 DO_FCALL 0 $17
32 SEND_VAR $17
33 DO_ICALL $18
34 > RETURN $18
19 35* > RETURN null
End of function quicksort
Generated using Vulcan Logic Dumper, using php 8.0.0
preferences:
164.09 ms | 1403 KiB | 20 Q