note 118198 deleted from function.array-multisort by cmb
| From: | cmb@php.net | Date: | Sun, 29 Dec 2019 10:29:59 +0000 |
| Subject: | note 118198 deleted from function.array-multisort by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-213684@lists.php.net to get a copy of this message | ||
Note Submitter: intsystem88 at gmail dot com
----
See (rus): https://intsystem.org/coding/sortirovka-mnogomernyh-massivov-po-klyuchu-na-php/
Simple example:
<?php
$data=array(
array('text'=>'str1', 'year'=>'2010',
'author'=>10),
array('text'=>'str2', 'year'=>'2011',
'author'=>10),
array('text'=>'str3', 'year'=>'2009',
'author'=>20),
array('text'=>'str4', 'year'=>'2010',
'author'=>30),
array('text'=>'str5', 'year'=>'2010',
'author'=>20),
array('text'=>'str6', 'year'=>'2011',
'author'=>10),
array('text'=>'str7', 'year'=>'2011',
'author'=>20),
array('text'=>'str8', 'year'=>'2009',
'author'=>20),
);
$data_year=array();
foreach($data as $key=>$arr){
$data_year[$key]=$arr['year'];
}
for($i=0; $i<100000; $i++){
$data_tmp=$data;
array_multisort($data_year, SORT_NUMERIC, $data_tmp);
}
?>