3v4l.org

run code in 300+ PHP versions simultaneously
<?php weighted_sort2(array_flip(supported_types()), priority_types()); function supported_types() { static $types = array( 1 => "Terraced House", 2 => "End of terrace house", 3 => "Semi-detached house", 4 => "Detached house", 5 => "Mews house", 6 => "Cluster house", 7 => "Ground floor flat", 8 => "Flat", 9 => "Studio flat", 10 => "Ground floor maisonette", 11 => "Maisonette", 12 => "Bungalow", 13 => "Terraced bungalow", 14 => "Semi-detached bungalow", 15 => "Detached bungalow", 16 => "Mobile home", 20 => "Land", 21 => "Link detached house", 22 => "Town house", 23 => "Cottage", 24 => "Chalet", 26 => "House", 27 => "Villa", 28 => "Apartment", 29 => "Penthouse", 30 => "Finca", 43 => "Barn Conversion", 44 => "Serviced apartment", 45 => "Parking", 46 => "Sheltered Housing", 47 => "Retirement property", 48 => "House share", 49 => "Flat share", 50 => "Park home", 51 => "Garages", 52 => "Farm House", 53 => "Equestrian facility", 56 => "Duplex", 59 => "Triplex", 62 => "Longere", 65 => "Gite", 68 => "Barn", 71 => "Trulli", 74 => "Mill", 77 => "Ruins", 80 => "Restaurant", 83 => "Cafe", 86 => "Mill", 92 => "Castle", 95 => "Village House", 101 => "Cave House", 104 => "Cortijo", 107 => "Farm Land", 110 => "Plot", 113 => "Country House", 116 => "Stone House", 117 => "Caravan", 118 => "Lodge", 119 => "Log Cabin", 120 => "Manor House", 121 => "Stately Home", 125 => "Off-Plan", 128 => "Semi-detached Villa", 131 => "Detached Villa", 134 => "Bar/Nightclub", 137 => "Shop", 140 => "Riad", 141 => "House Boat", 142 => "Hotel Room", 143 => "Block of Apartments", 144 => "Private Halls", 178 => "Office", 181 => "Business Park", 184 => "Serviced Office", 187 => "Retail Property (High Street)", 190 => "Retail Property (Out of Town)", 193 => "Convenience Store", 196 => "Garages", 199 => "Hairdresser/Barber Shop", 202 => "Hotel", 205 => "Petrol Station", 208 => "Post Office", 211 => "Pub", 214 => "Workshop & Retail Space", 217 => "Distribution Warehouse", 220 => "Factory", 223 => "Heavy Industrial", 226 => "Industrial Park", 229 => "Light Industrial", 232 => "Storage", 235 => "Showroom", 238 => "Warehouse", 241 => "Land", 244 => "Commercial Development", 247 => "Industrial Development", 250 => "Residential Development", 253 => "Commercial Property", 256 => "Data Centre", 259 => "Farm", 262 => "Healthcare Facility", 265 => "Marine Property", 268 => "Mixed Use", 271 => "Research & Development Facility", 274 => "Science Park", 277 => "Guest House", 280 => "Hospitality", 283 => "Leisure Facility", ); return $types; } function priority_types() { // Types that should take elevated priority. // This could also be defined in config so that clients can choose a priority // for items which may help reduce some confusion. static $priority = array( "Terraced bungalow" => 2, "Semi-detached bungalow" => 2, "Detached bungalow" => 2, "Studio flat" => 1, "Equestrian facility" => 1, "Bungalow" => 1, "Retirement property" => 1, "Barn Conversion" => 1, "Apartment" => 1, "Garages" => -1 ); return $priority; } function weighted_sort(array $input, array $weights) { $tmp = array_merge(array(), $input); do { $high = array(); $middle = array(); $low = array(); foreach ($tmp as $key => $value) { if (($hasWeight = isset($weights[$key]))) { $weight =& $weights[$key]; } if (!$hasWeight) { $middle[$key] = $value; } else if ($weight > 0) { $high[$key] = $value; $weight--; } else if ($weight < 0) { $low[$key] = $value; $weight++; } if ($hasWeight && $weight === 0) { unset($weights[$key]); } } $tmp = array(); foreach (array($high, $middle, $low) as $array) { foreach ($array as $key => $value) { $tmp[$key] = $value; } } } while (count($weights) > 0); return $tmp; } function weighted_sort2(array $input, array $weights) { $tmp = $input; do { $high = array(); $middle = array(); $low = array(); foreach ($tmp as $key => $value) { if (($hasWeight = isset($weights[$key]))) { $weight =& $weights[$key]; } if (!$hasWeight) { $middle[$key] = $value; } else if ($weight > 0) { $high[$key] = $value; $weight--; } else if ($weight < 0) { $low[$key] = $value; $weight++; } if ($hasWeight && $weight === 0) { unset($weights[$key]); if (count($weights) === 0) { break; } } } $tmp = array(); foreach (array($high, $middle, $low) as $array) { foreach ($array as $key => $value) { $tmp[$key] = $value; } } } while (count($weights) > 0); return $tmp; }

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.0060.00916.75
8.3.50.0160.00617.98
8.3.40.0040.01118.89
8.3.30.0140.00319.39
8.3.20.0070.00020.38
8.3.10.0090.00020.40
8.3.00.0030.00519.38
8.2.180.0090.00618.16
8.2.170.0120.00322.96
8.2.160.0130.00020.39
8.2.150.0000.00824.18
8.2.140.0080.00024.66
8.2.130.0140.00026.16
8.2.120.0060.00319.38
8.2.110.0060.00320.51
8.2.100.0000.01218.03
8.2.90.0070.00319.39
8.2.80.0060.00317.97
8.2.70.0000.00817.63
8.2.60.0030.00517.78
8.2.50.0000.00818.07
8.2.40.0000.00918.16
8.2.30.0040.00419.38
8.2.20.0040.00417.88
8.2.10.0000.00918.06
8.2.00.0040.00417.78
8.1.270.0030.00623.92
8.1.260.0070.01126.35
8.1.250.0060.00928.09
8.1.240.0060.00323.84
8.1.230.0080.00419.17
8.1.220.0050.00317.74
8.1.210.0000.00918.77
8.1.200.0240.00317.09
8.1.190.0050.00317.38
8.1.180.0050.00318.10
8.1.170.0030.00618.45
8.1.160.0000.00722.00
8.1.150.0000.00718.91
8.1.140.0000.00717.39
8.1.130.0030.00317.86
8.1.120.0000.00717.48
8.1.110.0040.00417.38
8.1.100.0000.00817.39
8.1.90.0070.00017.52
8.1.80.0000.00817.36
8.1.70.0080.00017.49
8.1.60.0030.00517.54
8.1.50.0060.00317.59
8.1.40.0040.00417.54
8.1.30.0000.00817.66
8.1.20.0030.00517.53
8.1.10.0030.00517.57
8.1.00.0000.00817.40
8.0.300.0060.00318.77
8.0.290.0080.00016.75
8.0.280.0070.00018.48
8.0.270.0040.00417.29
8.0.260.0080.00017.34
8.0.250.0000.00717.07
8.0.240.0030.00316.89
8.0.230.0030.00316.85
8.0.220.0000.00716.93
8.0.210.0030.00316.95
8.0.200.0070.00016.98
8.0.190.0030.00916.95
8.0.180.0020.00516.98
8.0.170.0080.00016.93
8.0.160.0070.00016.91
8.0.150.0050.00216.88
8.0.140.0030.00616.79
8.0.130.0030.00613.39
8.0.120.0080.00016.95
8.0.110.0040.00416.94
8.0.100.0070.00016.95
8.0.90.0060.00317.05
8.0.80.0130.00316.93
8.0.70.0000.00716.97
8.0.60.0080.00016.91
8.0.50.0000.00816.99
8.0.30.0080.01417.21
8.0.20.0120.00717.43
8.0.10.0070.00016.91
8.0.00.0080.01516.72
7.4.330.0050.00015.07
7.4.320.0060.00316.64
7.4.300.0030.00516.45
7.4.290.0080.00016.59
7.4.280.0000.00716.63
7.4.270.0070.00016.47
7.4.260.0030.00316.42
7.4.250.0040.00416.61
7.4.240.0040.00416.58
7.4.230.0050.00316.72
7.4.220.0000.02016.58
7.4.210.0100.01016.63
7.4.200.0040.00416.66
7.4.160.0130.00716.46
7.4.150.0100.01017.40
7.4.140.0150.00317.86
7.4.130.0140.00916.51
7.4.120.0100.00716.54
7.4.110.0040.01316.49
7.4.100.0000.01716.52
7.4.90.0150.00316.77
7.4.80.0130.01019.39
7.4.70.0080.01016.53
7.4.60.0080.00816.46
7.4.50.0040.00416.56
7.4.40.0110.01116.41
7.4.30.0030.01316.43
7.4.00.0000.01414.94
7.3.330.0040.00213.26
7.3.320.0000.00513.27
7.3.310.0000.00716.35
7.3.300.0000.00716.39
7.3.290.0140.00616.31
7.3.280.0090.00816.36
7.3.270.0130.00617.40
7.3.260.0130.00316.63
7.3.250.0030.01316.50
7.3.240.0060.01616.66
7.3.230.0130.00316.58
7.3.210.0060.01216.62
7.3.200.0140.00319.39
7.3.190.0060.01216.36
7.3.180.0030.01316.39
7.3.170.0080.01416.41
7.3.160.0070.01016.42
7.3.10.0030.01016.69
7.3.00.0070.01016.56
7.2.330.0060.01316.71
7.2.320.0120.00616.45
7.2.310.0120.00616.54
7.2.300.0120.00616.70
7.2.290.0060.01016.56
7.2.130.0060.00917.02
7.2.120.0000.01317.01
7.2.110.0040.01217.01
7.2.100.0130.00316.95
7.2.90.0030.00716.80
7.2.80.0030.01016.82
7.2.70.0070.00716.85
7.2.60.0120.00316.85
7.2.50.0040.01116.79
7.2.40.0030.01016.89
7.2.30.0060.00916.91
7.2.20.0070.00717.07
7.2.10.0040.00816.92
7.2.00.0030.00918.10
7.1.250.0040.01115.85
7.1.100.0000.01018.15
7.1.70.0040.00417.32
7.1.60.0070.01317.32
7.1.50.0120.01216.98
7.1.00.0100.06722.36
7.0.200.0060.00816.85
7.0.140.0100.06722.10
7.0.60.0030.08319.97
7.0.50.0100.05718.00
7.0.40.0100.08320.11
7.0.30.0300.04320.07
7.0.20.0300.05020.23
7.0.10.0030.09020.30
7.0.00.0130.04320.24
5.6.280.0000.07720.95
5.6.210.0000.04320.57
5.6.200.0100.08318.15
5.6.190.0170.07320.63
5.6.180.0200.05020.48
5.6.170.0100.05020.55
5.6.160.0070.04320.39
5.6.150.0030.04318.14
5.6.140.0070.08318.18
5.6.130.0130.06718.17
5.6.120.0170.08021.05
5.6.110.0270.05021.04
5.6.100.0070.05720.95
5.6.90.0030.06021.05
5.6.80.0000.05020.55
5.6.70.0170.05320.33
5.5.350.0030.08320.45
5.5.340.0030.04318.09
5.5.330.0130.08320.21
5.5.320.0400.06720.33
5.5.310.0200.08020.35
5.5.300.0170.03718.08
5.5.290.0070.08718.04
5.5.280.0100.07021.00
5.5.270.0070.08320.71
5.5.260.0030.07321.02
5.5.250.0130.08020.50
5.5.240.0100.06720.20
5.4.450.0570.06019.39
5.4.440.0770.04719.61
5.4.430.0730.06019.53
5.4.420.0130.06719.47
5.4.410.0170.05719.57
5.4.400.0230.05318.88
5.4.390.0130.06019.29
5.4.380.0170.05718.65
5.4.370.0500.05018.82
5.4.360.0400.04718.82
5.4.350.0270.06318.59
5.4.340.0470.06718.80
5.4.320.0050.04312.59
5.4.310.0050.04012.59
5.4.300.0100.03712.59
5.4.290.0060.04012.59
5.4.280.0060.03512.48
5.4.270.0060.03612.49
5.4.260.0070.03612.48
5.4.250.0060.04012.49
5.4.240.0090.04112.49
5.4.230.0050.04112.48
5.4.220.0080.04012.48
5.4.210.0060.03612.48
5.4.200.0120.04912.47
5.4.190.0090.03612.47
5.4.180.0080.03412.47
5.4.170.0070.03812.48
5.4.160.0040.03812.48
5.4.150.0070.03512.47
5.4.140.0050.03812.16
5.4.130.0100.03912.14
5.4.120.0060.03512.10
5.4.110.0100.03212.09
5.4.100.0050.04912.10
5.4.90.0070.03512.09
5.4.80.0100.03412.10
5.4.70.0070.03912.09
5.4.60.0060.03612.09
5.4.50.0050.04112.09
5.4.40.0070.03312.09
5.4.30.0060.03412.08
5.4.20.0100.03112.07
5.4.10.0050.03612.08
5.4.00.0040.04311.57
5.3.290.0080.03812.84
5.3.280.0080.03612.77
5.3.270.0040.04212.78
5.3.260.0100.04212.78
5.3.250.0060.03712.77
5.3.240.0080.03512.78
5.3.230.0050.03812.77
5.3.220.0070.03712.74
5.3.210.0070.03912.73
5.3.200.0060.03912.74
5.3.190.0070.03712.74
5.3.180.0060.03712.73
5.3.170.0070.03612.73
5.3.160.0060.04312.73
5.3.150.0030.04312.73
5.3.140.0080.03412.73
5.3.130.0100.03512.72
5.3.120.0070.03912.71
5.3.110.0080.03712.72
5.3.100.0090.04712.21
5.3.90.0090.03712.19
5.3.80.0090.03412.18
5.3.70.0060.04312.18
5.3.60.0060.03812.17
5.3.50.0080.03512.12
5.3.40.0110.03112.12
5.3.30.0090.03212.07
5.3.20.0070.03411.86
5.3.10.0060.04011.82
5.3.00.0090.03311.80
5.2.170.0070.0289.32
5.2.160.0050.0309.32
5.2.150.0050.0339.32
5.2.140.0040.0319.32
5.2.130.0040.0309.28
5.2.120.0050.0289.28
5.2.110.0090.0299.29
5.2.100.0080.0279.27
5.2.90.0060.0379.27
5.2.80.0080.0319.27
5.2.70.0060.0299.27
5.2.60.0020.0339.23
5.2.50.0030.0329.20
5.2.40.0040.0309.17
5.2.30.0030.0329.13
5.2.20.0090.0279.12
5.2.10.0050.0289.03
5.2.00.0050.0378.90
5.1.60.0050.0258.20
5.1.50.0050.0298.19
5.1.40.0050.0308.17
5.1.30.0040.0268.52
5.1.20.0030.0348.54
5.1.10.0060.0308.27
5.1.00.0050.0298.27
5.0.50.0040.0206.68
5.0.40.0020.0216.54
5.0.30.0060.0296.36
5.0.20.0050.0186.31
5.0.10.0060.0176.30
5.0.00.0040.0306.29
4.4.90.0020.0174.78
4.4.80.0050.0164.76
4.4.70.0040.0164.75
4.4.60.0040.0194.76
4.4.50.0020.0164.77
4.4.40.0030.0254.71
4.4.30.0050.0144.76
4.4.20.0030.0154.85
4.4.10.0060.0124.85
4.4.00.0010.0274.76
4.3.110.0020.0194.67
4.3.100.0030.0154.67
4.3.90.0030.0154.63
4.3.80.0040.0234.59
4.3.70.0020.0174.63
4.3.60.0030.0174.63
4.3.50.0020.0164.63
4.3.40.0020.0294.54
4.3.30.0000.0183.34
4.3.20.0020.0163.32
4.3.10.0020.0163.27
4.3.00.0070.0337.38

preferences:
58.64 ms | 400 KiB | 5 Q