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.2.10.0040.00418.08
8.2.00.0040.00419.33
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.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:
10.54 ms | 403 KiB | 5 Q