3v4l.org

run code in 300+ PHP versions simultaneously
<?php $items = [ ['type' => 1, 'text' => 'A'], ['type' => 2, 'text' => 'B'], ['type' => 2, 'text' => 'C'], ['type' => 3, 'text' => 'D'], ['type' => 2, 'text' => 'E'], ['type' => 1, 'text' => 'F'], ['type' => 4, 'text' => 'G'], ['type' => 2, 'text' => 'H'], ['type' => 1, 'text' => 'I'], ['type' => 4, 'text' => 'J'], ['type' => 2, 'text' => 'K'], ['type' => 4, 'text' => 'L'], ['type' => 2, 'text' => 'M'], ['type' => 3, 'text' => 'N'], ['type' => 3, 'text' => 'O'], ['type' => 1, 'text' => 'P'], ['type' => 1, 'text' => 'Q'], ['type' => 2, 'text' => 'R'], ['type' => 3, 'text' => 'S'], ['type' => 2, 'text' => 'T'], ['type' => 3, 'text' => 'U'], ['type' => 2, 'text' => 'V'], ['type' => 3, 'text' => 'W'], ['type' => 2, 'text' => 'X'], ['type' => 4, 'text' => 'Y'], ['type' => 2, 'text' => 'Z'], ]; $maxConsecutive = 3; $grouped = []; foreach ($items as $row) { $grouped[$row['type']][] = $row; } ksort($grouped); $result = []; foreach ($grouped as &$group) { array_push($result, ...array_splice($group, 0, count($grouped) === 1 ? null : $maxConsecutive)); if ($group) { $grouped[] = $group; } } var_export($result);

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.4.120.0100.01022.19
8.4.110.0080.01322.51
8.4.100.0160.00420.48
8.4.90.0110.01020.55
8.4.80.0090.00922.51
8.4.70.0040.00417.80
8.4.60.0060.00518.60
8.4.50.0080.00818.70
8.4.40.0100.01017.75
8.4.30.0030.00618.66
8.4.20.0130.00720.60
8.4.10.0040.00419.52
8.3.250.0150.00518.86
8.3.240.0090.00916.66
8.3.230.0110.00916.81
8.3.220.0060.00419.18
8.3.210.0110.00816.63
8.3.200.0030.00716.92
8.3.190.0090.00619.18
8.3.180.0080.00716.55
8.3.170.0180.00319.02
8.3.160.0150.00320.27
8.3.150.0120.00617.26
8.3.140.0000.00817.16
8.3.130.0090.00018.30
8.3.120.0090.00020.73
8.3.110.0080.00020.94
8.3.100.0000.00824.06
8.3.90.0130.00626.77
8.3.80.0090.00018.30
8.3.70.0160.00616.88
8.3.60.0160.00618.43
8.3.50.0070.01016.73
8.3.40.0090.00620.22
8.3.30.0110.00421.91
8.3.20.0070.00024.18
8.3.10.0050.00324.66
8.3.00.0000.00826.16
8.2.290.0060.00520.59
8.2.280.0080.01218.52
8.2.270.0050.00317.47
8.2.260.0120.00618.37
8.2.250.0070.01418.36
8.2.240.0000.01018.82
8.2.230.0030.00722.58
8.2.220.0000.01037.54
8.2.210.0030.00626.77
8.2.200.0060.00318.41
8.2.190.0070.00716.58
8.2.180.0070.00716.63
8.2.170.0110.01118.95
8.2.160.0140.00422.96
8.2.150.0040.00425.66
8.2.140.0080.00024.66
8.2.130.0060.00326.16
8.2.120.0040.00420.87
8.2.110.0090.01222.27
8.2.100.0140.01020.90
8.2.90.0180.01120.59
8.2.80.0070.00718.91
8.2.70.0100.00718.94
8.2.60.0060.00618.77
8.2.50.0090.00021.74
8.2.40.0040.00818.86
8.2.30.0090.00020.47
8.2.20.0040.00420.94
8.2.10.0080.00418.80
8.2.00.0040.00718.78
8.1.330.0090.01021.79
8.1.320.0090.01116.04
8.1.310.0000.00818.64
8.1.300.0070.01417.85
8.1.290.0030.00630.84
8.1.280.0130.00725.92
8.1.270.0080.00022.19
8.1.260.0040.00426.35
8.1.250.0000.00728.09
8.1.240.0000.00920.51
8.1.230.0050.00520.30
8.1.220.0080.00418.54
8.1.210.0100.00319.52
8.1.200.0110.00318.33
8.1.190.0080.00321.52
8.1.180.0090.00318.39
8.1.170.0070.00718.57
8.1.160.0060.00618.86
8.1.150.0040.00820.61
8.1.140.0060.00618.67
8.1.130.0100.00018.61
8.1.120.0000.00918.58
8.1.110.0090.00019.82
8.1.100.0070.00318.46
8.1.90.0050.00518.53
8.1.80.0030.00618.48
8.1.70.0080.00018.91
8.1.60.0110.00318.55
8.1.50.0070.00318.68
8.1.40.0040.00818.59
8.1.30.0070.00318.99
8.1.20.0090.00018.77
8.1.10.0040.00818.81
8.1.00.0060.00318.79
8.0.300.0050.00517.82
8.0.290.0080.00417.80
8.0.280.0070.00317.86
8.0.270.0100.00017.72
8.0.260.0100.00720.17
8.0.250.0230.00417.88
8.0.240.0100.00017.88
8.0.230.0180.00018.24
8.0.220.0120.00017.72
8.0.210.0130.00617.84
8.0.200.0060.00617.82
8.0.190.0150.00318.39
8.0.180.0070.01017.96
8.0.170.0090.00017.87
8.0.160.0070.00717.88
8.0.150.0030.00617.71
8.0.140.0060.00617.82
8.0.130.0080.00318.09
8.0.120.0100.00617.87
8.0.110.0100.00018.12
8.0.100.0050.00517.74
8.0.90.0070.00417.88
8.0.80.0050.00517.70
8.0.70.0040.00417.75
8.0.60.0030.00618.05
8.0.50.0090.00017.98
8.0.30.0060.00318.17
8.0.20.0000.00818.08
8.0.10.0040.00417.99

preferences:
28.81 ms | 403 KiB | 5 Q