3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array( array('product_code' => 'battle-for-zendikar-token-1', 'product' => 'battle-for-zendikar-token-1'), array('product_code' => 'battle-for-zendikar-token-2', 'product' => 'battle-for-zendikar-token-2'), array('product_code' => 'battle-for-zendikar-token-3', 'product' => 'battle-for-zendikar-token-3'), array('product_code' => 'battle-for-zendikar-token-4', 'product' => 'battle-for-zendikar-token-4'), array('product_code' => 'battle-for-zendikar-token-5', 'product' => 'battle-for-zendikar-token-5'), array('product_code' => 'battle-for-zendikar-token-6', 'product' => 'battle-for-zendikar-token-6'), array('product_code' => 'battle-for-zendikar-token-7', 'product' => 'battle-for-zendikar-token-7'), array('product_code' => 'battle-for-zendikar-token-8', 'product' => 'battle-for-zendikar-token-8'), array('product_code' => 'battle-for-zendikar-token-9', 'product' => 'battle-for-zendikar-token-9'), array('product_code' => 'battle-for-zendikar-token-10', 'product' => 'battle-for-zendikar-token-10'), array('product_code' => 'battle-for-zendikar-token-11', 'product' => 'battle-for-zendikar-token-11'), array('product_code' => 'battle-for-zendikar-token-12', 'product' => 'battle-for-zendikar-token-12'), array('product_code' => 'battle-for-zendikar-token-13', 'product' => 'battle-for-zendikar-token-13'), array('product_code' => 'battle-for-zendikar-token-14', 'product' => 'battle-for-zendikar-token-14'), array('product_code' => 'battle-for-zendikar-1', 'product' => 'battle-for-zendikar-1'), array('product_code' => 'battle-for-zendikar-2', 'product' => 'battle-for-zendikar-2'), array('product_code' => 'battle-for-zendikar-3', 'product' => 'battle-for-zendikar-3'), array('product_code' => 'battle-for-zendikar-4', 'product' => 'battle-for-zendikar-4'), array('product_code' => 'battle-for-zendikar-5', 'product' => 'battle-for-zendikar-5'), array('product_code' => 'battle-for-zendikar-6', 'product' => 'battle-for-zendikar-6'), array('product_code' => 'battle-for-zendikar-7', 'product' => 'battle-for-zendikar-7'), array('product_code' => 'battle-for-zendikar-8', 'product' => 'battle-for-zendikar-8'), array('product_code' => 'battle-for-zendikar-9', 'product' => 'battle-for-zendikar-9'), array('product_code' => 'battle-for-zendikar-10', 'product' => 'battle-for-zendikar-10'), array('product_code' => 'battle-for-zendikar-11', 'product' => 'battle-for-zendikar-11'), array('product_code' => 'battle-for-zendikar-12', 'product' => 'battle-for-zendikar-12'), array('product_code' => 'battle-for-zendikar-13', 'product' => 'battle-for-zendikar-13'), array('product_code' => 'battle-for-zendikar-14', 'product' => 'battle-for-zendikar-14'), array('product_code' => 'battle-for-zendikar-15', 'product' => 'battle-for-zendikar-15'), array('product_code' => 'battle-for-zendikar-16', 'product' => 'battle-for-zendikar-16'), array('product_code' => 'battle-for-zendikar-17', 'product' => 'battle-for-zendikar-17'), array('product_code' => 'battle-for-zendikar-18', 'product' => 'battle-for-zendikar-18'), array('product_code' => 'battle-for-zendikar-19', 'product' => 'battle-for-zendikar-19'), array('product_code' => 'battle-for-zendikar-20', 'product' => 'battle-for-zendikar-20') ); function sortProducts($products) { $_sorted = array(); $_unsortable = array(); $_numbers = array(); if (is_array($products) && count($products)) { foreach ($products as $product) { preg_match('/[0-9]+$/', $product['product_code'], $_numbers); $_number = $_numbers[0]; $initial_code_part = substr($product['product_code'],0,strrpos($product['product_code'],$_number)); if (!empty($_number)) { $_sorted[$initial_code_part][$_number] = $product; continue; } $_unsortable[$product['product_code']] = $product; } if (count($_sorted) > 1) { $_newSortedData = array(); foreach ($_sorted as $_sortKey => $_sortedData) { if (!count($_newSorteddata)) { $_newSortedData = $_sortedData; } else { $params = $_sorteddata; array_shift($params,$_newSortedData); call_user_func_array('array_push',$params); } } $_sorted = $_newSortedData; } ksort($_sorted); ksort($_unsortable); if (!count($_sorted)) { return $_unsortable; } return $_sorted + $_unsortable; } return $products; } var_dump(sortProducts($arr));

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.00718.93
8.3.50.0180.00321.23
8.3.40.0120.00319.08
8.3.30.0110.00419.09
8.3.20.0040.00420.18
8.3.10.0000.00821.77
8.3.00.0090.00019.69
8.2.180.0110.00417.00
8.2.170.0070.01122.96
8.2.160.0080.00820.58
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0060.00317.88
8.2.110.0060.00322.19
8.2.100.0090.00317.88
8.2.90.0090.00019.17
8.2.80.0000.00817.97
8.2.70.0060.00317.88
8.2.60.0040.00418.03
8.2.50.0060.00318.07
8.2.40.0000.00719.28
8.2.30.0030.00619.87
8.2.20.0080.00017.89
8.2.10.0000.00818.25
8.2.00.0070.00018.05
8.1.280.0040.01125.92
8.1.270.0060.00320.50
8.1.260.0040.00426.35
8.1.250.0080.00028.09
8.1.240.0090.00022.67
8.1.230.0080.00417.48
8.1.220.0050.00317.74
8.1.210.0000.00818.77
8.1.200.0060.00317.48
8.1.190.0050.00317.48
8.1.180.0000.00818.10
8.1.170.0000.00818.87
8.1.160.0000.00921.99
8.1.150.0040.00418.88
8.1.140.0000.00817.63
8.1.130.0000.00717.74
8.1.120.0040.00417.59
8.1.110.0000.00817.67
8.1.100.0070.00017.63
8.1.90.0000.00817.52
8.1.80.0000.00717.66
8.1.70.0030.00317.68
8.1.60.0040.00417.77
8.1.50.0040.00417.68
8.1.40.0030.00617.71
8.1.30.0060.00617.77
8.1.20.0050.00317.77
8.1.10.0000.00817.71
8.1.00.0000.00917.70
8.0.300.0040.00418.77
8.0.290.0040.00417.00
8.0.280.0060.00318.49
8.0.270.0000.00717.34
8.0.260.0070.00017.25
8.0.250.0040.00417.21
8.0.240.0030.00317.15
8.0.230.0000.00717.14
8.0.220.0000.00817.00
8.0.210.0080.00017.12
8.0.200.0000.00717.20
8.0.190.0000.00817.10
8.0.180.0000.00817.14
8.0.170.0080.00017.18
8.0.160.0000.00717.18
8.0.150.0030.00617.09
8.0.140.0040.00417.08
8.0.130.0030.00313.51
8.0.120.0040.00417.00
8.0.110.0030.00517.10
8.0.100.0000.00717.14
8.0.90.0040.00417.00
8.0.80.0100.00717.16
8.0.70.0000.00817.07
8.0.60.0040.00416.95
8.0.50.0050.00217.15
8.0.30.0090.00817.41
8.0.20.0190.00617.40
8.0.10.0040.00417.23
8.0.00.0030.01716.96
7.4.330.0030.00315.16
7.4.320.0050.00316.60
7.4.300.0030.00316.82
7.4.290.0050.00516.81
7.4.280.0070.00316.74
7.4.270.0030.00316.83
7.4.260.0040.00416.64
7.4.250.0050.00316.71
7.4.240.0040.00416.74
7.4.230.0070.00016.77
7.4.220.0060.01016.77
7.4.210.0140.00716.82
7.4.200.0070.00016.85
7.4.160.0140.00616.49
7.4.150.0100.01017.40
7.4.140.0100.01017.86
7.4.130.0120.01516.78
7.4.120.0110.01216.81
7.4.110.0060.01316.63
7.4.100.0150.00616.64
7.4.90.0130.00716.59
7.4.80.0090.00919.39
7.4.70.0060.01516.76
7.4.60.0110.00816.81
7.4.50.0000.00916.76
7.4.40.0140.00816.76
7.4.30.0090.01516.69
7.4.10.0050.01115.13
7.4.00.0070.00815.13
7.3.330.0060.00013.61
7.3.320.0050.00013.44
7.3.310.0040.00416.65
7.3.300.0000.00716.45
7.3.290.0070.00016.66
7.3.280.0120.00916.62
7.3.270.0080.01417.40
7.3.260.0070.01116.62
7.3.250.0130.00716.70
7.3.240.0150.00416.66
7.3.230.0080.01116.90
7.3.210.0100.00916.61
7.3.200.0060.01616.71
7.3.190.0060.01216.77
7.3.180.0110.00716.60
7.3.170.0190.00016.75
7.3.160.0030.01916.55
7.3.130.0110.00915.11
7.3.120.0030.01315.18
7.3.110.0080.01115.09
7.3.100.0050.00915.01
7.3.90.0050.00915.15
7.3.80.0050.00914.93
7.3.70.0050.01014.90
7.3.60.0040.00815.06
7.3.50.0070.00515.04
7.3.40.0070.01115.01
7.3.30.0070.01314.82
7.3.20.0050.00916.96
7.3.10.0040.01016.90
7.3.00.0030.01016.93
7.2.330.0110.00816.90
7.2.320.0190.00016.68
7.2.310.0120.00616.86
7.2.300.0100.01016.93
7.2.290.0040.02116.80
7.2.260.0080.01115.24
7.2.250.0110.00715.19
7.2.240.0030.01215.02
7.2.230.0050.01215.43
7.2.220.0050.01315.41
7.2.210.0090.00715.20
7.2.200.0060.01015.12
7.2.190.0090.00715.04
7.2.180.0100.01015.25
7.2.170.0090.00515.37
7.2.160.0060.01415.20
7.2.150.0070.00917.24
7.2.140.0070.00717.28
7.2.130.0070.00617.13
7.2.120.0060.00917.16
7.2.110.0070.01017.18
7.2.100.0080.00817.14
7.2.90.0090.00617.19
7.2.80.0040.01117.21
7.2.70.0060.01017.10
7.2.60.0120.00717.17
7.2.50.0040.01017.16
7.2.40.0060.01017.23
7.2.30.0090.00517.21
7.2.20.0030.01217.15
7.2.10.0070.00917.27
7.2.00.0090.00617.76
7.1.330.0060.00816.10
7.1.320.0080.00516.04
7.1.310.0070.00916.16
7.1.300.0060.00815.90
7.1.290.0100.00616.06
7.1.280.0080.00515.99
7.1.270.0060.00616.04
7.1.260.0050.01116.18
7.1.250.0080.00615.97
7.1.240.0050.00916.04
7.1.230.0030.01016.08
7.1.220.0020.01116.00
7.1.210.0090.00515.80
7.1.200.0030.01116.00
7.1.190.0050.01016.07
7.1.180.0050.00815.93
7.1.170.0110.00616.04
7.1.160.0060.01115.92
7.1.150.0060.00616.10
7.1.140.0070.00915.99
7.1.130.0070.00815.89
7.1.120.0000.01116.02
7.1.110.0030.01016.04
7.1.100.0170.01016.54
7.1.90.0050.01216.09
7.1.80.0060.00615.89
7.1.70.0080.00616.40
7.1.60.0050.01117.12
7.1.50.0050.00916.40
7.1.40.0050.00716.17
7.1.30.0040.00615.96
7.1.20.0020.00716.07
7.1.10.0080.00315.80
7.1.00.0010.03218.18
7.0.330.0040.00915.58
7.0.320.0020.01315.41
7.0.310.0050.00915.57
7.0.300.0050.00815.51
7.0.290.0070.00815.40
7.0.280.0060.00815.37
7.0.270.0070.01015.50
7.0.260.0120.00215.26
7.0.250.0090.00715.65
7.0.240.0110.00315.66
7.0.230.0070.00515.70
7.0.220.0050.00515.67
7.0.210.0050.01215.64
7.0.200.0040.01115.99
7.0.190.0050.01015.65
7.0.180.0060.00715.46
7.0.170.0050.00715.55
7.0.160.0090.00415.50
7.0.150.0040.00715.38
7.0.140.0050.00915.64
7.0.130.0030.00815.58
7.0.120.0050.03117.81
7.0.110.0070.01917.73
7.0.100.0080.01917.68
7.0.90.0010.02017.57
7.0.80.0050.02117.72
7.0.70.0030.03217.59
7.0.60.0030.02317.70
7.0.50.0050.03217.86
7.0.40.0040.02115.97
7.0.30.0050.03115.81
7.0.20.0040.01915.83
7.0.10.0070.01715.85
7.0.00.0070.01815.99
5.6.400.0070.00714.84
5.6.390.0110.00314.64
5.6.380.0090.00714.18
5.6.370.0090.00714.83
5.6.360.0050.01214.69
5.6.350.0060.00714.40
5.6.340.0070.00814.56
5.6.330.0040.01314.64
5.6.320.0130.00514.63
5.6.310.0020.01314.67
5.6.300.0040.01314.59
5.6.290.0060.00514.83
5.6.280.0030.01616.73
5.6.270.0060.03416.73
5.6.260.0080.01816.81
5.6.250.0030.02116.73
5.6.240.0060.01916.79
5.6.230.0080.02016.71
5.6.220.0050.01816.84
5.6.210.0020.02116.69
5.6.200.0030.03216.74
5.6.190.0070.02016.80
5.6.180.0040.03116.67
5.6.170.0060.02916.73
5.6.160.0050.02416.68
5.6.150.0040.03216.55
5.6.140.0040.01816.92
5.6.130.0050.02116.60
5.6.120.0060.01716.62
5.6.110.0070.03116.63
5.6.100.0030.01916.61
5.6.90.0060.01816.76
5.6.80.0040.03116.47
5.6.70.0100.02816.43
5.6.60.0020.02116.41
5.6.50.0070.02716.41
5.6.40.0080.02816.58
5.6.30.0020.03116.47
5.6.20.0050.03316.48
5.6.10.0040.03216.42
5.6.00.0050.03216.37
5.5.380.0090.01515.54
5.5.370.0060.01915.56
5.5.360.0040.01815.48
5.5.350.0060.01715.53
5.5.340.0040.01815.61
5.5.330.0050.03015.80
5.5.320.0030.03215.72
5.5.310.0030.02515.64
5.5.300.0030.02515.79
5.5.290.0040.01815.63
5.5.280.0050.03115.75
5.5.270.0080.01715.77
5.5.260.0020.02115.57
5.5.250.0020.02715.50
5.5.240.0050.02715.55
5.5.230.0050.02915.44
5.5.220.0030.03315.33
5.5.210.0060.02715.47
5.5.200.0060.01815.36
5.5.190.0060.01515.43
5.5.180.0040.02815.36
5.5.170.0070.01014.26
5.5.160.0040.03215.41
5.5.150.0030.03715.39
5.5.140.0050.03015.22
5.5.130.0050.02315.49
5.5.120.0060.01715.38
5.5.110.0030.02715.42
5.5.100.0070.01515.26
5.5.90.0070.01315.39
5.5.80.0050.03015.35
5.5.70.0040.02915.34
5.5.60.0030.01915.30
5.5.50.0050.02815.59
5.5.40.0050.01915.20
5.5.30.0070.02815.25
5.5.20.0050.02715.36
5.5.10.0050.01715.32
5.5.00.0060.02915.36
5.4.450.0040.01915.48
5.4.440.0020.01915.50
5.4.430.0030.02315.40
5.4.420.0010.02115.48
5.4.410.0050.01415.38
5.4.400.0040.02415.31
5.4.390.0030.02315.31
5.4.380.0060.02315.39
5.4.370.0040.01615.43
5.4.360.0040.02615.37
5.4.350.0030.01715.39
5.4.340.0090.01815.37
5.4.330.0040.00413.49
5.4.320.0050.02815.35
5.4.310.0070.01815.30
5.4.300.0070.02615.38
5.4.290.0030.01915.39
5.4.280.0030.01915.30
5.4.270.0010.02115.38
5.4.260.0030.02715.43
5.4.250.0060.02515.31
5.4.240.0040.02615.40
5.4.230.0040.01515.43
5.4.220.0050.01415.28
5.4.210.0070.01315.34
5.4.200.0080.01315.31
5.4.190.0020.02715.38
5.4.180.0070.02115.31
5.4.170.0060.02715.34
5.4.160.0050.01815.38
5.4.150.0080.02715.31
5.4.140.0050.03014.52
5.4.130.0090.02214.45
5.4.120.0090.02514.52
5.4.110.0070.01414.51
5.4.100.0030.02614.52
5.4.90.0060.02514.47
5.4.80.0020.02714.51
5.4.70.0040.02914.53
5.4.60.0040.02914.46
5.4.50.0030.01614.46
5.4.40.0060.02814.52
5.4.30.0070.02614.47
5.4.20.0050.02614.50
5.4.10.0020.03214.42
5.4.00.0040.02814.27

preferences:
60.18 ms | 401 KiB | 5 Q