3v4l.org

run code in 300+ PHP versions simultaneously
<?php $indexes = [ 26 => ["namespace" => "X\\Y\\Zed"], 9 => ["namespace" => "A\\B\\See"], 3 => ["namespace" => "A\\B\\Bee"], 38 => ["namespace" => "A\\B\\C\\Dee"], 51 => ["namespace" => "X\\Wye"], 16 => ["namespace" => "A\\Sea"], 12 => ["namespace" => "A\\Bees"], ]; uasort( $indexes, static function (array $a, array $b) { $aPath = $a['namespace']; $bPath = $b['namespace']; // Just in case there are duplicates if ($aPath === $bPath) { return 0; } // Break into parts $aParts = explode('\\', $aPath); $bParts = explode('\\', $bPath); // If we only have a single thing then it is a root-level, just compare the item if (1 === count($aParts) && 1 === count($bParts)) { return $aPath <=> $bPath; } // Get the class and namespace (file and folder) parts $aClass = array_pop($aParts); $bClass = array_pop($bParts); $aNamespace = implode('\\', $aParts); $bNamespace = implode('\\', $bParts); // If the namespaces are the same, sort by class name if ($aNamespace === $bNamespace) { return $aClass <=> $bClass; } // If the first namespace _starts_ with the second namespace, sort it first if (0 === mb_strpos($aNamespace, $bNamespace)) { return -1; } // Same as above but the other way if (0 === mb_strpos($bNamespace, $aNamespace)) { return 1; } // Just only by namespace return $aNamespace <=> $bNamespace; } ); $expected = [ 38 => ["namespace" => "A\\B\\C\\Dee"], 3 => ["namespace" => "A\\B\\Bee"], 9 => ["namespace" => "A\\B\\See"], 12 => ["namespace" => "A\\Bees"], 16 => ["namespace" => "A\\Sea"], 26 => ["namespace" => "X\\Y\\Zed"], 51 => ["namespace" => "X\\Wye"], ]; assert($indexes === $expected);

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.130.0120.00518.87
8.4.120.0110.01024.12
8.4.110.0140.00620.62
8.4.100.0120.00818.79
8.4.90.0050.01220.61
8.4.80.0120.00917.93
8.4.70.0090.00417.88
8.4.60.0100.01019.04
8.4.50.0070.00517.80
8.4.40.0060.01319.55
8.4.30.0030.00620.49
8.4.20.0150.00318.07
8.4.10.0090.00020.73
8.3.250.0110.00819.05
8.3.240.0120.00516.96
8.3.230.0070.00516.47
8.3.220.0070.01019.04
8.3.210.0040.00316.47
8.3.200.0080.01016.66
8.3.190.0030.00617.21
8.3.180.0100.00916.57
8.3.170.0130.00618.68
8.3.160.0140.00418.29
8.3.150.0090.00620.75
8.3.140.0040.00418.36
8.3.130.0050.00318.41
8.3.120.0050.00320.75
8.3.110.0030.00620.94
8.3.100.0050.00316.65
8.3.90.0110.00726.77
8.3.80.0030.00618.56
8.3.70.0090.00616.75
8.3.60.0090.00616.63
8.3.50.0070.01123.57
8.3.40.0070.01123.65
8.3.30.0150.00018.75
8.3.20.0040.00424.18
8.3.10.0050.00524.66
8.3.00.0040.00426.16
8.2.290.0060.00120.72
8.2.280.0040.00418.51
8.2.270.0160.00317.26
8.2.260.0110.00718.66
8.2.250.0150.00616.67
8.2.240.0000.00819.21
8.2.230.0090.00022.58
8.2.220.0060.00324.06
8.2.210.0000.00826.77
8.2.200.0060.00316.75
8.2.190.0120.00316.75
8.2.180.0120.00625.92
8.2.170.0140.00019.04
8.2.160.0140.00022.96
8.2.150.0090.00025.66
8.2.140.0000.00924.66
8.2.130.0080.00026.16
8.2.120.0040.00419.66
8.2.110.0110.00022.23
8.2.100.0110.00019.26
8.2.90.0050.00318.16
8.2.80.0050.00320.36
8.2.70.0040.00418.03
8.2.60.0080.00018.28
8.2.50.0050.00618.10
8.2.40.0040.00419.13
8.2.30.0040.00419.25
8.2.20.0040.00418.15
8.2.10.0060.00319.27
8.2.00.0050.00219.21
8.1.330.0090.00921.80
8.1.320.0100.00620.34
8.1.310.0090.00916.76
8.1.300.0060.00318.11
8.1.290.0080.00330.84
8.1.280.0150.00025.92
8.1.270.0030.00623.90
8.1.260.0000.00926.35
8.1.250.0080.00028.09
8.1.240.0080.00023.91
8.1.230.0080.00321.02
8.1.220.0000.00817.79
8.1.210.0040.00418.97
8.1.200.0000.00917.25
8.1.190.0030.00517.35
8.1.180.0090.00018.10
8.1.170.0060.00318.59
8.1.160.0040.00419.09
8.1.150.0060.00318.96
8.1.140.0040.00418.97
8.1.130.0030.00320.18
8.1.120.0000.00717.33
8.1.110.0040.00417.49
8.1.100.0040.00417.39
8.1.90.0040.00417.54
8.1.80.0070.00317.38
8.1.70.0030.00317.56
8.1.60.0000.00917.66
8.1.50.0030.00617.62
8.1.40.0040.00417.50
8.1.30.0050.00517.61
8.1.20.0000.00817.79
8.1.10.0000.00717.65
8.1.00.0080.00417.50
8.0.300.0030.00520.20
8.0.290.0050.00316.88
8.0.280.0040.00418.54
8.0.270.0030.00316.91
8.0.260.0030.00320.21
8.0.250.0030.00317.10
8.0.240.0000.00616.94
8.0.230.0000.00717.08
8.0.220.0000.00716.96
8.0.210.0040.00416.89
8.0.200.0000.00717.00
8.0.190.0050.00217.05
8.0.180.0040.00416.96
8.0.170.0040.00417.02
8.0.160.0040.00417.00
8.0.150.0070.00016.87
8.0.140.0000.00716.93
8.0.130.0050.00013.40
8.0.120.0000.00716.92
8.0.110.0040.00416.93
8.0.100.0040.00416.91
8.0.90.0000.00716.88
8.0.80.0110.00716.93
8.0.70.0000.00817.05
8.0.60.0070.00016.78
8.0.50.0040.00416.83
8.0.30.0110.00617.22
8.0.20.0100.01017.09
8.0.10.0040.00416.99
8.0.00.0140.01016.77
7.4.330.0020.00215.55
7.4.320.0060.00016.59
7.4.300.0030.00316.61
7.4.290.0000.00816.60
7.4.280.0000.00716.52
7.4.270.0030.00316.55
7.4.260.0070.00016.53
7.4.250.0060.00316.48
7.4.240.0000.00816.39
7.4.230.0030.00316.51
7.4.220.0070.00016.46
7.4.210.0060.00916.59
7.4.200.0000.00716.73
7.4.130.0120.00716.58
7.4.120.0170.00916.52
7.4.110.0060.01116.49
7.4.100.0120.00616.63
7.4.90.0080.01216.63
7.4.80.0110.00616.46
7.4.70.0060.01316.61
7.4.60.0070.01116.44
7.4.50.0040.01516.74
7.4.40.0080.00816.44
7.4.30.0080.01016.59
7.4.20.0180.00016.50
7.4.10.0030.01416.66
7.4.00.0090.01016.45
7.3.330.0000.00716.43
7.3.320.0070.00013.21
7.3.310.0080.00016.44
7.3.300.0000.00716.30
7.3.290.0060.01116.42
7.3.260.0140.00316.38
7.3.230.0110.00616.63
7.3.220.0110.00716.48
7.3.210.0080.01216.50
7.3.200.0100.00716.60
7.3.190.0030.01416.59
7.3.180.0070.01416.61
7.3.170.0030.01416.47
7.3.160.0030.01416.27
7.3.150.0140.00316.59
7.3.140.0080.00816.54
7.3.130.0030.01316.48
7.3.120.0090.00916.51
7.3.110.0110.00616.35
7.3.100.0120.00416.42
7.3.90.0150.00316.40
7.3.80.0080.00816.48
7.3.70.0060.01216.48
7.3.60.0060.01216.32
7.3.50.0100.00716.31
7.3.40.0100.00716.49
7.3.30.0100.00716.25
7.3.20.0110.00816.31
7.3.10.0070.01016.38
7.3.00.0110.01116.33
7.2.340.0040.01516.39
7.2.330.0090.01316.50
7.2.320.0090.00916.69
7.2.310.0130.00316.58
7.2.300.0100.01016.66
7.2.290.0110.01116.64
7.2.280.0140.00616.73
7.2.270.0210.00016.85
7.2.260.0080.01116.80
7.2.250.0150.00416.86
7.2.240.0120.00416.75
7.2.230.0130.00316.81
7.2.220.0130.00416.77
7.2.210.0110.00516.73
7.2.200.0100.00716.81
7.2.190.0030.01416.68
7.2.180.0090.00916.48
7.2.170.0060.01216.63
7.2.160.0070.01016.69
7.2.150.0070.01016.73
7.2.140.0140.01016.56
7.2.130.0100.01016.69
7.2.120.0100.01316.70
7.2.110.0140.00416.68
7.2.100.0040.02016.57
7.2.90.0060.01916.91
7.2.80.0090.01516.72
7.2.70.0100.01416.55
7.2.60.0160.00316.70
7.2.50.0190.00016.66
7.2.40.0130.00716.77
7.2.30.0140.00316.80
7.2.20.0080.01016.69
7.2.10.0140.00516.58
7.2.00.0120.00616.73

preferences:
95.41 ms | 403 KiB | 5 Q