<?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_ASC, $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.215934753418E-5
Array
(
[0] => Array
(
[type] => fruit
[price] => 3.5
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => pork
[price] => 5.43
)
)
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
- 1.0013580322266E-5
6.1988830566406E-6
Array
(
[0] => Array
(
[type] => fruit
[price] => 3.5
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => pork
[price] => 5.43
)
)
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
- 5.0067901611328E-6
5.9604644775391E-6
Array
(
[0] => Array
(
[type] => fruit
[price] => 3.5
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => pork
[price] => 5.43
)
)
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
- 5.9604644775391E-6
6.9141387939453E-6
Array
(
[0] => Array
(
[type] => fruit
[price] => 3.5
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => pork
[price] => 5.43
)
)
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.3828277587891E-5
1.4066696166992E-5
Array
(
[0] => Array
(
[type] => fruit
[price] => 3.5
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => pork
[price] => 5.43
)
)
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.215934753418E-5
1.1920928955078E-5
Array
(
[0] => Array
(
[type] => fruit
[price] => 3.5
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => pork
[price] => 5.43
)
)
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] => fruit
[price] => 3.5
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => pork
[price] => 5.43
)
)
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.215934753418E-5
1.3113021850586E-5
Array
(
[0] => Array
(
[type] => fruit
[price] => 3.5
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => pork
[price] => 5.43
)
)
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.5020370483398E-5
1.4066696166992E-5
Array
(
[0] => Array
(
[type] => fruit
[price] => 3.5
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => pork
[price] => 5.43
)
)
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 - 7.1.1
- 1.0967254638672E-5
1.0967254638672E-5
Array
(
[0] => Array
(
[type] => fruit
[price] => 3.5
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => pork
[price] => 5.43
)
)
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.5974044799805E-5
7.1525573730469E-6
Array
(
[0] => Array
(
[type] => fruit
[price] => 3.5
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => pork
[price] => 5.43
)
)
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
- 1.5020370483398E-5
1.1920928955078E-5
Array
(
[0] => Array
(
[type] => fruit
[price] => 3.5
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => pork
[price] => 5.43
)
)
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.5974044799805E-5
1.0967254638672E-5
Array
(
[0] => Array
(
[type] => fruit
[price] => 3.5
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => pork
[price] => 5.43
)
)
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.8835067749023E-5
1.5020370483398E-5
Array
(
[0] => Array
(
[type] => fruit
[price] => 3.5
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => pork
[price] => 5.43
)
)
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
- 2.0980834960938E-5
1.2874603271484E-5
Array
(
[0] => Array
(
[type] => fruit
[price] => 3.5
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => pork
[price] => 5.43
)
)
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.15
- 1.8119812011719E-5
1.4066696166992E-5
Array
(
[0] => Array
(
[type] => fruit
[price] => 3.5
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => pork
[price] => 5.43
)
)
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.14
- 1.5020370483398E-5
1.0967254638672E-5
Array
(
[0] => Array
(
[type] => fruit
[price] => 3.5
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => pork
[price] => 5.43
)
)
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
- 2.0027160644531E-5
1.5974044799805E-5
Array
(
[0] => Array
(
[type] => fruit
[price] => 3.5
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => pork
[price] => 5.43
)
)
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, 7.0.12
- 1.4066696166992E-5
1.0967254638672E-5
Array
(
[0] => Array
(
[type] => fruit
[price] => 3.5
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => pork
[price] => 5.43
)
)
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] => fruit
[price] => 3.5
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => pork
[price] => 5.43
)
)
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.2874603271484E-5
Array
(
[0] => Array
(
[type] => fruit
[price] => 3.5
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => pork
[price] => 5.43
)
)
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.6212463378906E-5
1.215934753418E-5
Array
(
[0] => Array
(
[type] => fruit
[price] => 3.5
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => pork
[price] => 5.43
)
)
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] => fruit
[price] => 3.5
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => pork
[price] => 5.43
)
)
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.978874206543E-5
1.215934753418E-5
Array
(
[0] => Array
(
[type] => fruit
[price] => 3.5
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => pork
[price] => 5.43
)
)
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.215934753418E-5
1.0013580322266E-5
Array
(
[0] => Array
(
[type] => fruit
[price] => 3.5
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => pork
[price] => 5.43
)
)
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] => fruit
[price] => 3.5
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => pork
[price] => 5.43
)
)
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.0013580322266E-5
Array
(
[0] => Array
(
[type] => fruit
[price] => 3.5
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => pork
[price] => 5.43
)
)
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.1205673217773E-5
5.0067901611328E-6
Array
(
[0] => Array
(
[type] => fruit
[price] => 3.5
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => pork
[price] => 5.43
)
)
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
- 1.0013580322266E-5
1.1920928955078E-5
Array
(
[0] => Array
(
[type] => fruit
[price] => 3.5
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => pork
[price] => 5.43
)
)
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.0013580322266E-5
5.9604644775391E-6
Array
(
[0] => Array
(
[type] => fruit
[price] => 3.5
)
[1] => Array
(
[type] => milk
[price] => 2.9
)
[2] => Array
(
[type] => pork
[price] => 5.43
)
)
Array
(
[fruit] => Array
(
[type] => fruit
[price] => 3.5
)
[milk] => Array
(
[type] => milk
[price] => 2.9
)
[pork] => Array
(
[type] => pork
[price] => 5.43
)
)
preferences:
65.57 ms | 402 KiB | 37 Q