題目:
$a = [
[1,2,3],
[1,2,4],
[1,3,4],
[1,0,9]
];
對該資料進行排序,寫一段程式根據第二列進行排序,可使用php内置的函數
<?php
$a = [
[1,2,3],
[1,2,4],
[1,3,4],
[1,0,9]
];
$res = [];
foreach($a as $value){
$res[serialize($value)] = $value[1];
}
asort($res);
$final = [];
foreach($res as $key=>$value){
$final[] = unserialize($key);
}
var_dump($final);