php-根据身高排序,在根据重量排序


$one = [
    'one' => [
        'height' => 175 ,
        'weight' => 50
    ]
];

$two = [
    'two' => [
        'height' => 172 ,
        'weight' => 60
    ]
];

$three = [
    'three' => [
        'height' => 172,
        'weight' => 50
    ],
    'four'=>[
        'height' => 173,
        'weight' => 50
    ]
];

$all = array_merge( $one , $two ,$three);

// 取得列的列表
foreach ($all as $key => $row) {
    $weight[$key]  = $row['weight'];
    $height[$key] = $row['height'];
}

//var_dump($weight);exit;
array_multisort( $height ,  SORT_ASC , $weight ,SORT_DESC ,$all );


print_r($all);

你可能感兴趣的:(php)