2011-07-03 55 views
1

陣列排序多維數組,但不重新分配頂級鍵

$tagHolder[$row['id']] = array(


     "name" => $row['name'], 
     "primary" => $row['primary'], 
     "child" => $row['child'], 
     "order" => $row['order'] 

    ); 

usort功能

function sortAsc($x, $y){ 
if ($x['order'] == $y['order']) 
return 0; 
else if ($x['order'] < $y['order']) 
return -1; 
else 
return 1; 
} 

將被「秩序」順序,但不會保留原來的$row['id']鍵,取而代之的則將第一個主題重新分配爲0等等。我如何進行排序功能排序,但保持$row['key']不變?

回答