3v4l.org

run code in 300+ PHP versions simultaneously
<?php $orderList = [ 'Jake', 'Scully' => [ 'pet', 'friend' => [ 'Michael', 'Merissa', ], 'Norm', ], 'Amy', 'Charles', 'Hitchcock', ]; $items = [ [ 'name' => 'Scully' ], [ 'name' => 'Rosa' ], [ 'name' => 'Bill' ], [ 'name' => 'Jake' ], [ 'name' => 'Hitchcock' ], [ 'name' => 'Amy' ], ]; function getTopLevelItemsFromMixedList(array $mixedList): array { $topLevels = []; foreach ($mixedList as $item => $value) { $topLevels[] = is_int($item) ? $value : $item; } return $topLevels; } function sort_by(array $array, callable $sortKeyResolver, ...$sortArgs) { $mapped = array_map($sortKeyResolver, $array); asort($mapped, ...$sortArgs); $sorted = []; foreach ($mapped as $key => $index) { $sorted[] = $array[$key]; } return $sorted; } $topLevelOrder = getTopLevelItemsFromMixedList($orderList); $sortKeyResolver = function ($item) use ($topLevelOrder) { $orderListIndex = array_search($item['name'], $topLevelOrder); return $orderListIndex === false ? count($topLevelOrder).$item['name'] : $orderListIndex; }; print_r(sort_by($items, $sortKeyResolver, SORT_NATURAL));

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.20.0100.01019.51
8.4.10.0100.00321.92
8.3.150.0150.00420.76
8.3.140.0030.00516.56
8.3.130.0030.00916.69
8.3.120.0080.00018.82
8.3.110.0060.00320.94
8.3.100.0120.00824.06
8.3.90.0130.00326.77
8.3.80.0060.00316.36
8.3.70.0130.00616.63
8.3.60.0070.01116.49
8.3.50.0040.01118.41
8.3.40.0170.00020.34
8.3.30.0180.00418.88
8.3.20.0040.00424.18
8.3.10.0000.00924.66
8.3.00.0000.00826.16
8.2.260.0000.01019.28
8.2.250.0070.00716.41
8.2.240.0060.00317.40
8.2.230.0080.00022.58
8.2.220.0060.00337.54
8.2.210.0040.01126.77
8.2.200.0040.00416.75
8.2.190.0140.00716.58
8.2.180.0150.00025.92
8.2.170.0100.01018.95
8.2.160.0110.01122.96
8.2.150.0090.00625.66
8.2.140.0070.00024.66
8.2.130.0040.00426.16
8.2.120.0040.00420.63
8.2.110.0070.00322.30
8.2.100.0040.00817.91
8.2.90.0050.00319.25
8.2.80.0000.00818.05
8.2.70.0040.00417.63
8.2.60.0030.00517.91
8.2.50.0090.00018.07
8.2.40.0050.00318.28
8.2.30.0030.00518.07
8.2.20.0050.00219.21
8.2.10.0040.00418.08
8.2.00.0040.00419.33
8.1.310.0030.00716.65
8.1.300.0070.00016.29
8.1.290.0030.00630.84
8.1.280.0070.01025.92
8.1.270.0000.00724.66
8.1.260.0050.00326.35
8.1.250.0040.00428.09
8.1.240.0040.00423.96
8.1.230.0030.00722.07
8.1.220.0080.00017.79
8.1.210.0000.00818.77
8.1.200.0090.00317.35
8.1.190.0000.00817.35
8.1.180.0060.00318.10
8.1.170.0040.00418.66
8.1.160.0030.00618.92
8.1.150.0040.00418.73
8.1.140.0050.00217.52
8.1.130.0030.00319.09
8.1.120.0000.00717.44
8.1.110.0000.00717.38
8.1.100.0010.00717.38
8.1.90.0070.01017.43
8.1.80.0130.00317.40
8.1.70.0130.00317.46
8.1.60.0130.00417.61
8.1.50.0130.00217.53
8.1.40.0150.00317.62
8.1.30.0130.00517.62
8.1.20.0100.00617.65
8.1.10.0130.00417.56
8.1.00.0130.00517.50
8.0.300.0060.00318.77
8.0.290.0040.00416.75
8.0.280.0030.00620.14
8.0.270.0040.00318.13
8.0.260.0040.00418.50
8.0.250.0030.00317.06
8.0.240.0000.00716.93
8.0.230.0130.00216.94
8.0.220.0130.00216.82
8.0.210.0110.00416.97
8.0.200.0100.00516.97
8.0.190.0090.00516.89
8.0.180.0100.00616.96
8.0.170.0080.00816.91
8.0.160.0090.00616.93
8.0.150.0080.00816.85
8.0.140.0120.00216.91
8.0.130.0150.00016.92
8.0.120.0110.00416.97
8.0.110.0090.00516.90
8.0.100.0100.00616.82
8.0.90.0110.00416.92
8.0.80.0090.00716.80
8.0.70.0100.00516.81
8.0.60.0130.00216.95
8.0.50.0090.00616.88
8.0.30.0080.00816.85
8.0.20.0090.00716.90
8.0.10.0090.00317.02
7.4.330.0050.00015.55
7.4.320.0030.00316.54
7.4.300.0130.00216.46
7.4.290.0100.00316.59
7.4.280.0100.00416.52
7.4.270.0060.00416.61
7.4.260.0120.00216.50
7.4.250.0060.00416.51
7.4.240.0060.01016.56
7.4.230.0080.00616.50
7.4.220.0080.00616.61
7.4.210.0070.00716.64
7.4.200.0100.00516.53
7.4.190.0110.00316.60
7.4.180.0110.00316.60
7.4.160.0120.00216.62
7.4.150.0130.00116.52
7.4.140.0100.00316.48
7.4.130.0100.00416.41
7.4.120.0090.00616.38
7.4.110.0090.00516.50
7.4.100.0110.00416.58
7.4.90.0110.00316.39
7.4.80.0090.00516.57
7.4.70.0130.00116.47
7.4.60.0110.00416.36
7.4.50.0140.00016.31
7.4.40.0120.00216.35
7.4.30.0100.00316.44
7.4.20.0110.00316.44
7.4.10.0110.00416.49
7.4.00.0130.00316.60

preferences:
56.5 ms | 403 KiB | 5 Q