3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a=array(array(207306,'Bob',''), array (199730,'Sam',199714), array(199728,'Simon',207306), array(199714,'John',207306), array(199716,'Tom',199718), array(199718,'Phillip',207306), array(199720,'James',207306)); # map the children by parent $parents = ['' => []]; foreach ($a as $val) { $parents[$val[2]][] = $val; } # start with those with no parent $sorted = $parents['']; # add the children the current nodes are parent of until the array is empty # a bit slower loop which works in all versions for ($val = reset($sorted); $val; $val = next($sorted)) { if (isset($parents[$val[0]])) { foreach ($parents[$val[0]] as $next) { $sorted[] = $next; } } } var_dump($sorted);

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.3.60.0070.00716.50
8.3.50.0140.00522.09
8.3.40.0100.01018.86
8.3.30.0040.01118.71
8.3.20.0080.00020.16
8.3.10.0100.00523.70
8.3.00.0060.00322.44
8.2.180.0120.00625.92
8.2.170.0060.00918.89
8.2.160.0080.00519.38
8.2.150.0070.00024.18
8.2.140.0030.00524.66
8.2.130.0050.00326.16
8.2.120.0000.00719.85
8.2.110.0070.00321.06
8.2.100.0080.00417.70
8.2.90.0080.00017.84
8.2.80.0050.00518.04
8.2.70.0080.00018.05
8.2.60.0000.00817.63
8.2.50.0030.00618.10
8.2.40.0050.00320.61
8.2.30.0040.00419.38
8.2.20.0040.00417.77
8.2.10.0070.00018.13
8.2.00.0050.00317.63
8.1.280.0070.01425.92
8.1.270.0000.00821.91
8.1.260.0080.00026.35
8.1.250.0000.00928.09
8.1.240.0030.00622.16
8.1.230.0090.00322.73
8.1.220.0000.00817.74
8.1.210.0050.00320.21
8.1.200.0000.00817.36
8.1.190.0060.00317.22
8.1.180.0060.00318.10
8.1.170.0050.00518.59
8.1.160.0040.00422.20
8.1.150.0000.00718.87
8.1.140.0040.00419.70
8.1.130.0040.00417.72
8.1.120.0030.00417.52
8.1.110.0040.00417.43
8.1.100.0000.00717.52
8.1.90.0050.00217.46
8.1.80.0030.00317.38
8.1.70.0040.00417.40
8.1.60.0030.00617.55
8.1.50.0040.00417.45
8.1.40.0040.00417.53
8.1.30.0000.00817.60
8.1.20.0030.00617.70
8.1.10.0060.00317.59
8.1.00.0000.00817.49
8.0.300.0050.00321.95
8.0.290.0080.00016.75
8.0.280.0030.00518.47
8.0.270.0040.00416.82
8.0.260.0030.00317.39
8.0.250.0070.00016.89
8.0.240.0080.00016.93
8.0.230.0030.00516.89
8.0.220.0000.00716.86
8.0.210.0000.00716.88
8.0.200.0000.00716.93
8.0.190.0000.00817.01
8.0.180.0040.00416.97
8.0.170.0040.00416.85
8.0.160.0040.00416.95
8.0.150.0000.00716.80
8.0.140.0080.00016.90
8.0.130.0060.00013.38
8.0.120.0030.00616.84
8.0.110.0000.00716.95
8.0.100.0040.00416.78
8.0.90.0080.00017.02
8.0.80.0110.00316.93
8.0.70.0190.00616.94
8.0.60.0160.01016.84
8.0.50.0210.00816.85
8.0.30.0090.01216.98
8.0.20.0150.00717.26
8.0.10.0130.00917.04
8.0.00.0110.01016.88
7.4.330.0060.00015.08
7.4.320.0000.00616.52
7.4.300.0030.00316.50
7.4.290.0000.00816.64
7.4.280.0000.00816.56
7.4.270.0070.00016.51
7.4.260.0030.00516.41
7.4.250.0080.00016.46
7.4.240.0040.00416.62
7.4.230.0030.00316.60
7.4.220.0110.00716.60
7.4.210.0060.00916.55
7.4.200.0150.01516.58
7.4.190.0220.00816.72
7.4.180.0280.00416.59
7.4.160.0150.00816.59
7.4.150.0140.00716.88
7.4.140.0130.00917.16
7.4.130.0110.01016.48
7.4.120.0160.01116.53
7.4.110.0170.00416.56
7.4.100.0080.01216.57
7.4.90.0100.01316.53
7.4.80.0160.00717.47
7.4.70.0150.00916.52
7.4.60.0080.01316.51
7.4.50.0140.00616.43
7.4.40.0110.00816.41
7.4.30.0100.00916.43
7.4.20.0120.00716.46
7.4.10.0210.00516.55
7.4.00.0140.00715.89
7.3.330.0050.00013.26
7.3.320.0030.00313.07
7.3.310.0030.00316.46
7.3.300.0070.00016.32
7.3.290.0040.00416.36
7.3.280.0080.01016.33
7.3.270.0140.00816.66
7.3.260.0110.01016.47
7.3.250.0120.00916.39
7.3.240.0150.00816.35
7.3.230.0170.00616.40
7.3.220.0150.00916.30
7.3.210.0110.01116.34
7.3.200.0090.01116.43
7.3.190.0130.00716.32
7.3.180.0110.01116.32
7.3.170.0120.01016.31
7.3.160.0180.00416.31
7.3.150.0150.00616.31
7.3.140.0180.01116.25
7.3.130.0210.00316.23
7.3.120.0110.01116.19
7.3.110.0150.01116.20
7.3.100.0120.01016.09
7.3.90.0110.01015.98
7.3.80.0080.01215.63
7.3.70.0170.00415.57
7.3.60.0110.00715.46
7.3.50.0110.00815.44
7.3.40.0110.00815.30
7.3.30.0080.01015.32
7.3.20.0140.00815.64
7.3.10.0150.00715.56
7.3.00.0070.01215.58
7.2.340.0180.01316.40
7.2.330.0140.01216.47
7.2.320.0140.01116.47
7.2.310.0130.01216.39
7.2.300.0160.01116.42
7.2.290.0130.01116.49
7.2.280.0230.01016.40
7.2.270.0160.00716.36
7.2.260.0190.01316.31
7.2.250.0210.00916.39
7.2.240.0170.01216.34
7.2.230.0170.01316.36
7.2.220.0160.00915.99
7.2.210.0130.01015.65
7.2.200.0180.00415.77
7.2.190.0120.00815.56
7.2.180.0130.00915.59
7.2.170.0120.00915.53
7.2.160.0120.01115.62
7.2.150.0090.01415.89
7.2.140.0210.00815.86
7.2.130.0170.00915.91
7.2.120.0200.00815.71
7.2.110.0180.01115.77
7.2.100.0220.00915.65
7.2.90.0230.01115.72
7.2.80.0250.00615.74
7.2.70.0170.00915.75
7.2.60.0190.00815.99
7.2.50.0350.00915.99
7.2.40.0300.00816.06
7.2.30.0190.00916.08
7.2.20.0290.01216.05
7.2.10.0190.00716.04
7.2.00.0220.00816.07
7.1.330.0550.00615.63
7.1.320.0150.01015.14
7.1.310.0130.01014.90
7.1.300.0080.01114.99
7.1.290.0290.00914.94
7.1.280.0210.01014.73
7.1.270.0160.00814.80
7.1.260.0140.00614.70
7.1.250.0080.01214.68
7.1.240.0180.01114.56
7.1.230.0820.01114.63
7.1.220.0170.00814.51
7.1.210.0190.00814.68
7.1.200.0300.00814.66
7.1.190.0220.00614.52
7.1.180.0300.00914.81
7.1.170.0180.00814.77
7.1.160.0240.00714.81
7.1.150.0170.01114.83
7.1.140.0200.00514.77
7.1.130.0180.00914.79
7.1.120.0210.01014.88
7.1.110.0200.00914.87
7.1.100.0200.00714.82
7.1.90.0160.00814.83
7.1.80.0210.01114.91
7.1.70.0220.00715.16
7.1.60.0130.00915.19
7.1.50.0140.01015.16
7.1.40.0170.00815.05
7.1.30.0160.00815.12
7.1.20.0240.00715.07
7.1.10.0130.00815.17
7.1.00.0180.01015.10
7.0.330.0140.00814.30
7.0.320.0240.00714.22
7.0.310.0260.01114.21
7.0.300.0230.00814.56
7.0.290.0210.00914.54
7.0.280.0240.00814.46
7.0.270.0190.00814.48
7.0.260.0200.01314.56
7.0.250.0180.00914.59
7.0.240.0210.00814.56
7.0.230.0180.00714.70
7.0.220.0210.00714.57
7.0.210.0210.00614.53
7.0.200.0190.00614.83
7.0.190.0170.00814.91
7.0.180.0130.01114.80
7.0.170.0190.00714.82
7.0.160.0160.01014.76
7.0.150.0180.00914.76
7.0.140.0230.00714.82
7.0.130.0190.00614.82
7.0.120.0160.00814.80
7.0.110.0170.00614.82
7.0.100.0170.00814.83
7.0.90.0230.01114.75
7.0.80.0170.00914.81
7.0.70.0150.00914.77
7.0.60.0190.00714.79
7.0.50.0160.00914.74
7.0.40.0220.00714.78
7.0.30.0230.00814.84
7.0.20.0170.00714.77
7.0.10.0400.00614.81
7.0.00.0150.00814.77
5.6.400.0120.00914.73
5.6.390.0110.01314.97
5.6.380.0120.01014.83
5.6.370.0170.00814.86
5.6.360.0180.00814.75
5.6.350.0150.00814.68
5.6.340.0150.00914.82
5.6.330.0170.00914.84
5.6.320.0120.01114.85
5.6.310.0140.01114.81
5.6.300.0120.01315.54
5.6.290.0150.01215.69
5.6.280.0150.01615.60
5.6.270.0120.02015.56
5.6.260.0110.01615.60
5.6.250.0120.01315.57
5.6.240.0140.01215.59
5.6.230.0120.01315.59
5.6.220.0110.01715.62
5.6.210.0140.01315.54
5.6.200.0140.01415.63
5.6.190.0140.01215.61
5.6.180.0130.01215.58
5.6.170.0140.01215.58
5.6.160.0130.01215.59
5.6.150.0140.01215.65
5.6.140.0140.01315.62
5.6.130.0150.01215.60
5.6.120.0140.01315.72
5.6.110.0130.01215.57
5.6.100.0110.01415.50
5.6.90.0150.01215.52
5.6.80.0130.01415.33
5.6.70.0130.01415.47
5.6.60.0130.01615.45
5.6.50.0130.01615.48
5.6.40.0120.01615.48
5.6.30.0150.01215.49
5.6.20.0140.01415.41
5.6.10.0140.01815.44
5.6.00.0140.01515.48

preferences:
61.18 ms | 401 KiB | 5 Q