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.0180.00418.57
8.3.50.0140.00921.35
8.3.40.0120.00319.04
8.3.30.0110.00419.05
8.3.20.0080.00020.16
8.3.10.0040.00421.77
8.3.00.0040.00419.68
8.2.180.0110.00718.54
8.2.170.0110.00722.96
8.2.160.0100.00320.35
8.2.150.0050.00324.18
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0080.00017.88
8.2.110.0040.00422.07
8.2.100.0030.00917.88
8.2.90.0030.00619.30
8.2.80.0060.00317.97
8.2.70.0000.00817.88
8.2.60.0040.00418.16
8.2.50.0000.00818.07
8.2.40.0030.00519.46
8.2.30.0040.00419.87
8.2.20.0040.00417.98
8.2.10.0070.00018.31
8.2.00.0000.00818.16
8.1.280.0100.00725.92
8.1.270.0090.00620.51
8.1.260.0040.00426.35
8.1.250.0000.00828.09
8.1.240.0030.00622.46
8.1.230.0040.00717.61
8.1.220.0090.00017.74
8.1.210.0050.00318.77
8.1.200.0000.00917.63
8.1.190.0050.00317.35
8.1.180.0080.00018.10
8.1.170.0040.00418.79
8.1.160.0080.00022.06
8.1.150.0040.00418.94
8.1.140.0000.00817.55
8.1.130.0000.00717.81
8.1.120.0000.00717.63
8.1.110.0040.00417.59
8.1.100.0000.00717.63
8.1.90.0000.00717.65
8.1.80.0000.00817.66
8.1.70.0000.00717.68
8.1.60.0030.00617.64
8.1.50.0080.00017.58
8.1.40.0030.00617.73
8.1.30.0130.00017.80
8.1.20.0050.00317.83
8.1.10.0000.00817.70
8.1.00.0030.00517.73
8.0.300.0040.00418.77
8.0.290.0040.00416.75
8.0.280.0000.00718.40
8.0.270.0000.00717.21
8.0.260.0000.00717.35
8.0.250.0040.00417.22
8.0.240.0030.00317.20
8.0.230.0040.00417.18
8.0.220.0050.00217.13
8.0.210.0000.00717.10
8.0.200.0060.00017.13
8.0.190.0000.00917.19
8.0.180.0030.00517.17
8.0.170.0080.00017.15
8.0.160.0030.00517.14
8.0.150.0000.00817.03
8.0.140.0050.00217.03
8.0.130.0030.00313.52
8.0.120.0050.00316.98
8.0.110.0070.00017.05
8.0.100.0040.00417.02
8.0.90.0000.00717.12
8.0.80.0000.01417.19
8.0.70.0040.00417.09
8.0.60.0050.00317.02
8.0.50.0050.00317.16
8.0.30.0090.00717.33
8.0.20.0110.01417.40
8.0.10.0060.00317.12
8.0.00.0090.00817.04
7.4.330.0040.00415.08
7.4.320.0000.00716.83
7.4.300.0060.00016.66
7.4.290.0060.00316.84
7.4.280.0090.00016.86
7.4.270.0070.00016.87
7.4.260.0040.00416.71
7.4.250.0000.00716.70
7.4.240.0040.00416.83
7.4.230.0040.00416.56
7.4.220.0000.01616.85
7.4.210.0030.01516.66
7.4.200.0030.00516.73
7.4.160.0070.01016.84
7.4.150.0130.01617.40
7.4.140.0180.00317.86
7.4.130.0160.01016.71
7.4.120.0130.00616.73
7.4.110.0180.00316.87
7.4.100.0130.01416.81
7.4.90.0060.01216.89
7.4.80.0120.00919.39
7.4.70.0100.01416.81
7.4.60.0090.00916.81
7.4.50.0090.00016.91
7.4.40.0070.01116.79
7.4.30.0140.01216.97
7.4.00.0090.01115.15
7.3.330.0000.00613.43
7.3.320.0030.00313.52
7.3.310.0030.00516.60
7.3.300.0040.00416.45
7.3.290.0000.00716.49
7.3.280.0070.01216.60
7.3.270.0190.00317.40
7.3.260.0180.00016.57
7.3.250.0070.01216.61
7.3.240.0140.00616.61
7.3.230.0150.00416.63
7.3.210.0180.00716.81
7.3.200.0100.01416.88
7.3.190.0070.01116.59
7.3.180.0050.01416.52
7.3.170.0090.01416.61
7.3.160.0140.00616.73
7.3.120.0090.00915.25
7.3.110.0130.00615.06
7.3.100.0030.00915.00
7.3.90.0100.00315.08
7.3.80.0000.01915.11
7.3.70.0060.00615.17
7.3.60.0030.01315.15
7.3.50.0000.01615.15
7.3.40.0030.00615.13
7.3.30.0070.01015.15
7.3.20.0070.00716.88
7.3.10.0070.00416.63
7.3.00.0100.00616.83
7.2.330.0160.00616.76
7.2.320.0060.01217.02
7.2.310.0090.00916.96
7.2.300.0140.00816.71
7.2.290.0070.01816.81
7.2.250.0070.01015.52
7.2.240.0120.00915.13
7.2.230.0060.00915.35
7.2.220.0070.00715.35
7.2.210.0030.01414.96
7.2.200.0090.00315.02
7.2.190.0040.01115.26
7.2.180.0030.01315.27
7.2.170.0060.00614.92
7.2.130.0110.00817.01
7.2.120.0090.01017.07
7.2.110.0090.00717.10
7.2.100.0090.00616.92
7.2.90.0080.01017.06
7.2.80.0050.01417.17
7.2.70.0120.00717.04
7.2.60.0090.00817.08
7.2.50.0050.01016.93
7.2.40.0090.00816.91
7.2.30.0120.00717.30
7.2.20.0140.00616.98
7.2.10.0120.01017.09
7.2.00.0090.00717.85
7.1.330.0080.00816.18
7.1.320.0050.00515.97
7.1.310.0030.00916.07
7.1.300.0100.00716.07
7.1.290.0090.00615.98
7.1.280.0030.01015.93
7.1.270.0060.01016.01
7.1.260.0100.00316.10
7.1.250.0060.00815.81
7.1.240.0060.00915.83
7.1.230.0050.01115.97
7.1.220.0070.00815.78
7.1.210.0110.00516.00
7.1.200.0120.00515.82
7.1.190.0090.00915.77
7.1.180.0140.00515.92
7.1.170.0070.01115.76
7.1.160.0120.00715.98
7.1.150.0130.00215.78
7.1.140.0070.00815.91
7.1.130.0090.00616.04
7.1.120.0080.00915.93
7.1.110.0140.00815.80
7.1.100.0150.01116.83
7.1.90.0090.00615.79
7.1.80.0150.00515.81
7.1.70.0070.00916.40
7.1.60.0090.00716.90
7.1.50.0060.01116.31
7.1.40.0090.00715.82
7.1.30.0130.00715.79
7.1.20.0040.01516.04
7.1.10.0070.01215.97
7.1.00.0120.03118.13
7.0.330.0130.00315.68
7.0.320.0190.00615.72
7.0.310.0100.00615.61
7.0.300.0110.00715.54
7.0.290.0110.01115.44
7.0.280.0120.00915.54
7.0.270.0060.01615.62
7.0.260.0140.00715.56
7.0.250.0080.00915.35
7.0.240.0080.01015.54
7.0.230.0130.00715.52
7.0.220.0100.00615.50
7.0.210.0120.00815.57
7.0.200.0150.00616.05
7.0.190.0100.00815.62
7.0.180.0180.00815.57
7.0.170.0070.00815.64
7.0.160.0120.00615.57
7.0.150.0160.00715.58
7.0.140.0110.01015.64
7.0.130.0040.01515.46
7.0.120.0140.00815.76
7.0.110.0100.00915.54
7.0.100.0060.00915.60
7.0.90.0120.00515.58
7.0.80.0130.00715.46
7.0.70.0080.00815.56
7.0.60.0070.03317.00
7.0.50.0080.03516.54
7.0.40.0070.02215.81
7.0.30.0260.02015.81
7.0.20.0120.02615.73
7.0.10.0020.02215.77
7.0.00.0100.02115.63
5.6.380.0080.00614.63
5.6.370.0090.00614.42
5.6.360.0080.00614.71
5.6.350.0060.00614.59
5.6.340.0040.01514.78
5.6.330.0100.00514.57
5.6.320.0080.01014.65
5.6.310.0050.00914.73
5.6.300.0080.00614.48
5.6.290.0060.01214.63
5.6.280.0040.02816.76
5.6.270.0050.01014.47
5.6.260.0050.00914.61
5.6.250.0060.00614.64
5.6.240.0060.00714.36
5.6.230.0130.00414.75
5.6.220.0070.00914.66
5.6.210.0080.01716.53
5.6.200.0070.03415.73
5.6.190.0090.01616.61
5.6.180.0130.02816.44
5.6.170.0100.02316.62
5.6.160.0090.02816.52
5.6.150.0080.03015.72
5.6.140.0080.01815.71
5.6.130.0100.01815.62
5.6.120.0020.02316.76
5.6.110.0040.02516.77
5.6.100.0040.03516.55
5.6.90.0070.02716.70
5.6.80.0080.03216.44
5.6.70.0130.03216.54
5.6.60.0060.01014.25
5.6.50.0050.01014.45
5.6.40.0100.00314.47
5.6.30.0160.00214.29
5.6.20.0110.00414.46
5.6.10.0070.00814.60
5.6.00.0100.00314.40
5.5.380.0040.00711.50
5.5.370.0040.00611.31
5.5.360.0080.00711.48
5.5.350.0170.02714.41
5.5.340.0020.02213.67
5.5.330.0060.03214.46
5.5.320.0130.01714.55
5.5.310.0090.03214.45
5.5.300.0020.02113.69
5.5.290.0060.01913.58
5.5.280.0070.02814.63
5.5.270.0100.02614.46
5.5.260.0090.02214.54
5.5.250.0030.03614.53
5.5.240.0080.02814.33
5.5.230.0040.00811.33
5.5.220.0070.00511.43
5.5.210.0100.00311.29
5.5.200.0060.00611.33
5.5.190.0030.00911.37
5.5.180.0050.00711.38
5.5.170.0070.00711.39
5.5.160.0060.00611.50
5.5.150.0040.01111.51
5.5.140.0050.00511.49
5.5.130.0040.00711.50
5.5.120.0040.00711.56
5.5.110.0070.00511.54
5.5.100.0120.00311.56
5.5.90.0130.00211.58
5.5.80.0040.00811.55
5.5.70.0080.00611.52
5.5.60.0070.00611.54
5.5.50.0040.00811.56
5.5.40.0020.01011.52
5.5.30.0050.00611.51
5.5.20.0050.00811.36
5.5.10.0050.00911.55
5.5.00.0050.00311.44
5.4.450.0100.02414.19
5.4.440.0060.02814.15
5.4.430.0110.02114.13
5.4.420.0100.02414.10
5.4.410.0100.02413.93
5.4.400.0100.02613.98
5.4.390.0090.02613.96
5.4.380.0120.02313.79
5.4.370.0110.02413.88
5.4.360.0080.02813.99
5.4.350.0130.02113.98
5.4.340.0120.02314.06
5.4.330.0090.00511.32
5.4.320.0110.02314.07
5.4.310.0150.01913.90
5.4.300.0140.02113.91
5.4.290.0130.02213.95
5.4.280.0120.02413.88
5.4.270.0120.02413.91
5.4.260.0130.02313.87
5.4.250.0090.02213.99
5.4.240.0060.02714.04
5.4.230.0110.02213.94
5.4.220.0090.02513.98
5.4.210.0120.02313.91
5.4.200.0080.02114.04
5.4.190.0100.02413.91
5.4.180.0170.02013.95
5.4.170.0110.02113.94
5.4.160.0150.02014.05
5.4.150.0130.02413.97
5.4.140.0100.02513.02
5.4.130.0130.02113.09
5.4.120.0110.02013.16
5.4.110.0090.02613.12
5.4.100.0160.01713.15
5.4.90.0120.02013.11
5.4.80.0100.02013.10
5.4.70.0070.02013.05
5.4.60.0100.03213.14
5.4.50.0070.02913.07
5.4.40.0080.02313.10
5.4.30.0090.01413.08
5.4.20.0060.02813.16
5.4.10.0040.00811.36
5.4.00.0050.00811.25

preferences:
72.98 ms | 401 KiB | 5 Q