<?php
$data = array(
array("type"=>"fruit", "price"=>3.50),
array("type"=>"milk", "price"=>2.90),
array("type"=>"pork", "price"=>5.43),
);
$inventory = $data;
$time = microtime(true);
array_multisort(array_column($inventory, 'type'), SORT_DESC, $inventory);
echo microtime(true)-$time;
echo "\n\n";
$new = [];
$time = microtime(true);
foreach($data as $row){
$new[$row['type']] = $row;
}
ksort($new);
echo microtime(true)-$time;
echo "\n\n";
print_r($inventory);
print_r($new);
- Output for 7.2.6
- 1.0013580322266E-5
1.2874603271484E-5
Array
(
[0] => Array
(
[type] => pork
[price] => 5.43
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => fruit
[price] => 3.5
)
)
Array
(
[fruit] => Array
(
[type] => fruit
[price] => 3.5
)
[milk] => Array
(
[type] => milk
[price] => 2.9
)
[pork] => Array
(
[type] => pork
[price] => 5.43
)
)
- Output for 7.2.0
- 8.8214874267578E-6
1.0013580322266E-5
Array
(
[0] => Array
(
[type] => pork
[price] => 5.43
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => fruit
[price] => 3.5
)
)
Array
(
[fruit] => Array
(
[type] => fruit
[price] => 3.5
)
[milk] => Array
(
[type] => milk
[price] => 2.9
)
[pork] => Array
(
[type] => pork
[price] => 5.43
)
)
- Output for 7.1.10
- 6.9141387939453E-6
1.215934753418E-5
Array
(
[0] => Array
(
[type] => pork
[price] => 5.43
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => fruit
[price] => 3.5
)
)
Array
(
[fruit] => Array
(
[type] => fruit
[price] => 3.5
)
[milk] => Array
(
[type] => milk
[price] => 2.9
)
[pork] => Array
(
[type] => pork
[price] => 5.43
)
)
- Output for 7.1.7
- 8.8214874267578E-6
1.1920928955078E-5
Array
(
[0] => Array
(
[type] => pork
[price] => 5.43
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => fruit
[price] => 3.5
)
)
Array
(
[fruit] => Array
(
[type] => fruit
[price] => 3.5
)
[milk] => Array
(
[type] => milk
[price] => 2.9
)
[pork] => Array
(
[type] => pork
[price] => 5.43
)
)
- Output for 7.1.6
- 1.1920928955078E-5
1.1205673217773E-5
Array
(
[0] => Array
(
[type] => pork
[price] => 5.43
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => fruit
[price] => 3.5
)
)
Array
(
[fruit] => Array
(
[type] => fruit
[price] => 3.5
)
[milk] => Array
(
[type] => milk
[price] => 2.9
)
[pork] => Array
(
[type] => pork
[price] => 5.43
)
)
- Output for 7.1.5
- 1.2874603271484E-5
1.0967254638672E-5
Array
(
[0] => Array
(
[type] => pork
[price] => 5.43
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => fruit
[price] => 3.5
)
)
Array
(
[fruit] => Array
(
[type] => fruit
[price] => 3.5
)
[milk] => Array
(
[type] => milk
[price] => 2.9
)
[pork] => Array
(
[type] => pork
[price] => 5.43
)
)
- Output for 7.1.4
- 1.1920928955078E-5
1.0967254638672E-5
Array
(
[0] => Array
(
[type] => pork
[price] => 5.43
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => fruit
[price] => 3.5
)
)
Array
(
[fruit] => Array
(
[type] => fruit
[price] => 3.5
)
[milk] => Array
(
[type] => milk
[price] => 2.9
)
[pork] => Array
(
[type] => pork
[price] => 5.43
)
)
- Output for 7.1.3
- 1.5974044799805E-5
1.4066696166992E-5
Array
(
[0] => Array
(
[type] => pork
[price] => 5.43
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => fruit
[price] => 3.5
)
)
Array
(
[fruit] => Array
(
[type] => fruit
[price] => 3.5
)
[milk] => Array
(
[type] => milk
[price] => 2.9
)
[pork] => Array
(
[type] => pork
[price] => 5.43
)
)
- Output for 7.1.2
- 1.215934753418E-5
1.0967254638672E-5
Array
(
[0] => Array
(
[type] => pork
[price] => 5.43
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => fruit
[price] => 3.5
)
)
Array
(
[fruit] => Array
(
[type] => fruit
[price] => 3.5
)
[milk] => Array
(
[type] => milk
[price] => 2.9
)
[pork] => Array
(
[type] => pork
[price] => 5.43
)
)
- Output for 7.1.1
- 1.5974044799805E-5
1.5974044799805E-5
Array
(
[0] => Array
(
[type] => pork
[price] => 5.43
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => fruit
[price] => 3.5
)
)
Array
(
[fruit] => Array
(
[type] => fruit
[price] => 3.5
)
[milk] => Array
(
[type] => milk
[price] => 2.9
)
[pork] => Array
(
[type] => pork
[price] => 5.43
)
)
- Output for 7.1.0
- 1.1920928955078E-5
1.0013580322266E-5
Array
(
[0] => Array
(
[type] => pork
[price] => 5.43
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => fruit
[price] => 3.5
)
)
Array
(
[fruit] => Array
(
[type] => fruit
[price] => 3.5
)
[milk] => Array
(
[type] => milk
[price] => 2.9
)
[pork] => Array
(
[type] => pork
[price] => 5.43
)
)
- Output for 7.0.20
- 1.4066696166992E-5
3.1948089599609E-5
Array
(
[0] => Array
(
[type] => pork
[price] => 5.43
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => fruit
[price] => 3.5
)
)
Array
(
[fruit] => Array
(
[type] => fruit
[price] => 3.5
)
[milk] => Array
(
[type] => milk
[price] => 2.9
)
[pork] => Array
(
[type] => pork
[price] => 5.43
)
)
- Output for 7.0.19
- 2.288818359375E-5
1.3113021850586E-5
Array
(
[0] => Array
(
[type] => pork
[price] => 5.43
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => fruit
[price] => 3.5
)
)
Array
(
[fruit] => Array
(
[type] => fruit
[price] => 3.5
)
[milk] => Array
(
[type] => milk
[price] => 2.9
)
[pork] => Array
(
[type] => pork
[price] => 5.43
)
)
- Output for 7.0.18
- 1.9073486328125E-5
1.5974044799805E-5
Array
(
[0] => Array
(
[type] => pork
[price] => 5.43
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => fruit
[price] => 3.5
)
)
Array
(
[fruit] => Array
(
[type] => fruit
[price] => 3.5
)
[milk] => Array
(
[type] => milk
[price] => 2.9
)
[pork] => Array
(
[type] => pork
[price] => 5.43
)
)
- Output for 7.0.17
- 1.7881393432617E-5
1.5020370483398E-5
Array
(
[0] => Array
(
[type] => pork
[price] => 5.43
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => fruit
[price] => 3.5
)
)
Array
(
[fruit] => Array
(
[type] => fruit
[price] => 3.5
)
[milk] => Array
(
[type] => milk
[price] => 2.9
)
[pork] => Array
(
[type] => pork
[price] => 5.43
)
)
- Output for 7.0.16
- 1.4066696166992E-5
9.0599060058594E-6
Array
(
[0] => Array
(
[type] => pork
[price] => 5.43
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => fruit
[price] => 3.5
)
)
Array
(
[fruit] => Array
(
[type] => fruit
[price] => 3.5
)
[milk] => Array
(
[type] => milk
[price] => 2.9
)
[pork] => Array
(
[type] => pork
[price] => 5.43
)
)
- Output for 7.0.1, 7.0.12, 7.0.14 - 7.0.15
- 1.5020370483398E-5
1.1920928955078E-5
Array
(
[0] => Array
(
[type] => pork
[price] => 5.43
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => fruit
[price] => 3.5
)
)
Array
(
[fruit] => Array
(
[type] => fruit
[price] => 3.5
)
[milk] => Array
(
[type] => milk
[price] => 2.9
)
[pork] => Array
(
[type] => pork
[price] => 5.43
)
)
- Output for 7.0.13
- 1.5974044799805E-5
1.1920928955078E-5
Array
(
[0] => Array
(
[type] => pork
[price] => 5.43
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => fruit
[price] => 3.5
)
)
Array
(
[fruit] => Array
(
[type] => fruit
[price] => 3.5
)
[milk] => Array
(
[type] => milk
[price] => 2.9
)
[pork] => Array
(
[type] => pork
[price] => 5.43
)
)
- Output for 7.0.11
- 1.3828277587891E-5
1.0013580322266E-5
Array
(
[0] => Array
(
[type] => pork
[price] => 5.43
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => fruit
[price] => 3.5
)
)
Array
(
[fruit] => Array
(
[type] => fruit
[price] => 3.5
)
[milk] => Array
(
[type] => milk
[price] => 2.9
)
[pork] => Array
(
[type] => pork
[price] => 5.43
)
)
- Output for 7.0.10
- 1.5020370483398E-5
1.1205673217773E-5
Array
(
[0] => Array
(
[type] => pork
[price] => 5.43
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => fruit
[price] => 3.5
)
)
Array
(
[fruit] => Array
(
[type] => fruit
[price] => 3.5
)
[milk] => Array
(
[type] => milk
[price] => 2.9
)
[pork] => Array
(
[type] => pork
[price] => 5.43
)
)
- Output for 7.0.9
- 1.5020370483398E-5
1.0013580322266E-5
Array
(
[0] => Array
(
[type] => pork
[price] => 5.43
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => fruit
[price] => 3.5
)
)
Array
(
[fruit] => Array
(
[type] => fruit
[price] => 3.5
)
[milk] => Array
(
[type] => milk
[price] => 2.9
)
[pork] => Array
(
[type] => pork
[price] => 5.43
)
)
- Output for 7.0.8
- 1.5020370483398E-5
1.0967254638672E-5
Array
(
[0] => Array
(
[type] => pork
[price] => 5.43
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => fruit
[price] => 3.5
)
)
Array
(
[fruit] => Array
(
[type] => fruit
[price] => 3.5
)
[milk] => Array
(
[type] => milk
[price] => 2.9
)
[pork] => Array
(
[type] => pork
[price] => 5.43
)
)
- Output for 7.0.7
- 1.6212463378906E-5
1.0967254638672E-5
Array
(
[0] => Array
(
[type] => pork
[price] => 5.43
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => fruit
[price] => 3.5
)
)
Array
(
[fruit] => Array
(
[type] => fruit
[price] => 3.5
)
[milk] => Array
(
[type] => milk
[price] => 2.9
)
[pork] => Array
(
[type] => pork
[price] => 5.43
)
)
- Output for 7.0.6
- 1.4781951904297E-5
1.0967254638672E-5
Array
(
[0] => Array
(
[type] => pork
[price] => 5.43
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => fruit
[price] => 3.5
)
)
Array
(
[fruit] => Array
(
[type] => fruit
[price] => 3.5
)
[milk] => Array
(
[type] => milk
[price] => 2.9
)
[pork] => Array
(
[type] => pork
[price] => 5.43
)
)
- Output for 7.0.5
- 1.0967254638672E-5
1.0967254638672E-5
Array
(
[0] => Array
(
[type] => pork
[price] => 5.43
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => fruit
[price] => 3.5
)
)
Array
(
[fruit] => Array
(
[type] => fruit
[price] => 3.5
)
[milk] => Array
(
[type] => milk
[price] => 2.9
)
[pork] => Array
(
[type] => pork
[price] => 5.43
)
)
- Output for 7.0.4
- 1.0967254638672E-5
1.0013580322266E-5
Array
(
[0] => Array
(
[type] => pork
[price] => 5.43
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => fruit
[price] => 3.5
)
)
Array
(
[fruit] => Array
(
[type] => fruit
[price] => 3.5
)
[milk] => Array
(
[type] => milk
[price] => 2.9
)
[pork] => Array
(
[type] => pork
[price] => 5.43
)
)
- Output for 7.0.3
- 1.0013580322266E-5
1.0967254638672E-5
Array
(
[0] => Array
(
[type] => pork
[price] => 5.43
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => fruit
[price] => 3.5
)
)
Array
(
[fruit] => Array
(
[type] => fruit
[price] => 3.5
)
[milk] => Array
(
[type] => milk
[price] => 2.9
)
[pork] => Array
(
[type] => pork
[price] => 5.43
)
)
- Output for 7.0.2
- 1.0967254638672E-5
5.0067901611328E-6
Array
(
[0] => Array
(
[type] => pork
[price] => 5.43
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => fruit
[price] => 3.5
)
)
Array
(
[fruit] => Array
(
[type] => fruit
[price] => 3.5
)
[milk] => Array
(
[type] => milk
[price] => 2.9
)
[pork] => Array
(
[type] => pork
[price] => 5.43
)
)
- Output for 7.0.0
- 1.0967254638672E-5
6.1988830566406E-6
Array
(
[0] => Array
(
[type] => pork
[price] => 5.43
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => fruit
[price] => 3.5
)
)
Array
(
[fruit] => Array
(
[type] => fruit
[price] => 3.5
)
[milk] => Array
(
[type] => milk
[price] => 2.9
)
[pork] => Array
(
[type] => pork
[price] => 5.43
)
)
preferences:
69.14 ms | 402 KiB | 37 Q