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); $_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.01318.52
8.3.50.0130.01021.16
8.3.40.0160.00619.08
8.3.30.0100.00718.92
8.3.20.0050.00320.13
8.3.10.0030.00621.63
8.3.00.0050.00319.69
8.2.180.0100.00716.75
8.2.170.0150.00422.96
8.2.160.0110.00420.38
8.2.150.0060.00324.18
8.2.140.0040.00424.66
8.2.130.0000.01126.16
8.2.120.0030.00617.88
8.2.110.0090.00022.20
8.2.100.0110.00018.00
8.2.90.0050.00519.38
8.2.80.0050.00518.00
8.2.70.0040.00418.00
8.2.60.0030.00618.15
8.2.50.0000.00818.07
8.2.40.0050.00319.27
8.2.30.0060.00320.06
8.2.20.0080.00018.04
8.2.10.0050.00318.23
8.2.00.0000.00718.16
8.1.280.0120.00325.92
8.1.270.0160.00320.26
8.1.260.0030.00526.35
8.1.250.0000.00828.09
8.1.240.0100.00022.49
8.1.230.0040.00817.48
8.1.220.0000.00917.80
8.1.210.0040.00418.77
8.1.200.0070.00317.50
8.1.190.0080.00017.36
8.1.180.0030.00618.10
8.1.170.0080.00018.77
8.1.160.0070.00021.97
8.1.150.0080.00018.93
8.1.140.0040.00417.68
8.1.130.0000.00717.76
8.1.120.0040.00417.62
8.1.110.0040.00417.67
8.1.100.0040.00417.57
8.1.90.0040.00417.62
8.1.80.0070.00017.52
8.1.70.0080.00017.52
8.1.60.0060.00317.65
8.1.50.0030.00617.57
8.1.40.0060.00317.73
8.1.30.0030.00817.80
8.1.20.0080.00017.72
8.1.10.0000.00817.63
8.1.00.0050.00317.62
8.0.300.0040.00418.77
8.0.290.0000.00717.00
8.0.280.0040.00418.49
8.0.270.0040.00417.23
8.0.260.0040.00417.29
8.0.250.0000.00817.08
8.0.240.0000.00717.18
8.0.230.0000.00817.06
8.0.220.0000.00717.14
8.0.210.0000.00717.05
8.0.200.0030.00317.10
8.0.190.0000.00817.19
8.0.180.0060.00317.03
8.0.170.0040.00417.06
8.0.160.0030.00517.14
8.0.150.0030.00617.00
8.0.140.0040.00417.05
8.0.130.0000.00613.56
8.0.120.0040.00416.93
8.0.110.0040.00417.07
8.0.100.0080.00016.95
8.0.90.0000.00816.94
8.0.80.0030.01517.11
8.0.70.0060.00317.06
8.0.60.0030.00517.01
8.0.50.0050.00317.11
8.0.30.0090.00917.22
8.0.20.0180.00717.44
8.0.10.0050.00317.26
8.0.00.0110.00916.94
7.4.330.0060.00015.09
7.4.320.0030.00316.82
7.4.300.0000.00616.66
7.4.290.0040.00416.82
7.4.280.0040.00416.73
7.4.270.0000.00716.89
7.4.260.0040.00416.63
7.4.250.0040.00416.59
7.4.240.0020.00616.72
7.4.230.0080.00016.92
7.4.220.0090.01216.77
7.4.210.0100.00816.75
7.4.200.0040.00416.87
7.4.160.0110.00616.61
7.4.150.0100.01217.40
7.4.140.0150.00517.86
7.4.130.0100.01316.75
7.4.120.0090.01016.73
7.4.110.0120.00916.65
7.4.100.0040.01616.84
7.4.90.0090.00916.70
7.4.80.0120.00619.39
7.4.70.0060.01216.84
7.4.60.0080.00816.63
7.4.50.0060.00316.53
7.4.40.0220.00016.71
7.4.30.0140.00716.78
7.4.00.0100.00715.02
7.3.330.0000.00513.55
7.3.320.0060.00013.56
7.3.310.0000.00716.41
7.3.300.0000.00716.60
7.3.290.0030.00316.41
7.3.280.0090.01016.54
7.3.270.0130.01017.40
7.3.260.0160.00316.52
7.3.250.0090.01116.69
7.3.240.0110.00816.53
7.3.230.0110.00816.62
7.3.210.0130.00516.46
7.3.200.0000.02416.54
7.3.190.0030.01716.81
7.3.180.0100.00916.78
7.3.170.0150.00816.54
7.3.160.0170.00516.54
7.2.330.0160.00617.05
7.2.320.0110.00816.86
7.2.310.0090.00917.10
7.2.300.0130.01016.83
7.2.290.0030.01616.87
7.2.00.0060.00919.80
7.1.100.0030.01318.10
7.1.70.0050.00517.38
7.1.60.0000.02319.12
7.1.50.0160.00617.16
7.1.00.0030.07722.43
7.0.200.0100.00316.73
7.0.60.0100.07719.96
7.0.50.0030.08018.03
7.0.40.0070.08020.28
7.0.30.0530.06320.35
7.0.20.0400.05320.08
7.0.10.0070.03720.07
7.0.00.0030.05720.22
5.6.280.0000.05720.93
5.6.210.0070.05720.64
5.6.200.0030.09318.20
5.6.190.0070.05020.67
5.6.180.0230.08320.39
5.6.170.0270.07720.47
5.6.160.0030.07720.54
5.6.150.0170.07318.17
5.6.140.0030.04018.19
5.6.130.0000.04718.18
5.6.120.0000.04321.18
5.6.110.0130.04321.02
5.6.100.0200.06721.06
5.6.90.0070.09021.04
5.6.80.0100.06320.47
5.6.70.0200.08020.56
5.5.350.0230.07720.42
5.5.340.0030.08318.08
5.5.330.0130.03720.40
5.5.320.0230.04320.24
5.5.310.0370.06020.52
5.5.300.0100.07717.97
5.5.290.0070.08018.07
5.5.280.0070.08321.00
5.5.270.0030.08720.91
5.5.260.0130.08020.67
5.5.250.0130.08320.65
5.5.240.0330.05720.16
5.4.450.0430.06719.34
5.4.440.0330.06019.54
5.4.430.0530.06319.54
5.4.420.0400.04319.40
5.4.410.0530.07319.04
5.4.400.0530.04319.17
5.4.390.0470.05019.25
5.4.380.0500.05719.09
5.4.370.0600.06719.23
5.4.360.0500.04019.20
5.4.350.0600.06019.05
5.4.340.0600.07018.98
5.4.320.0570.06318.85
5.4.310.0530.06719.24
5.4.300.0430.03719.32
5.4.290.0470.05719.04
5.4.280.0570.05718.87
5.4.270.0630.05718.94
5.4.260.0670.05718.85
5.4.250.0470.04019.15
5.4.240.0470.05718.98
5.4.230.0330.05019.20
5.4.220.0500.05719.07
5.4.210.0570.06019.22
5.4.200.0630.06318.86
5.4.190.0470.03719.17
5.4.180.0500.07319.30
5.4.170.0470.07018.84
5.4.160.0670.05319.22
5.4.150.0500.03719.11
5.4.140.0500.06716.36
5.4.130.0630.05316.46
5.4.120.0770.02716.36
5.4.110.0600.05716.60
5.4.100.0400.04016.50
5.4.90.0370.04716.33
5.4.80.0530.06316.40

preferences:
33.99 ms | 401 KiB | 5 Q