php,如何排序数组? [关闭]

i have this example:

while (...){
echo "test:'.$a.',- group:'.$m.'
}

this will give me something like:

test:name2 - group:7
test:name3 - group:10
test:name4 - group:3
...

how do i display these results ordered by group, ex:

test:name2 - group:10
test:name3 - group:7
test:name4 - group:3
...

any ideas? i believe i can use something like sort() or array_sort, bu t i don't know exactly

thanks.

edit: $a and m are arrays with the values echoed out.

edit2:

i see that many people don't understand my question, well it is very simple to understand. Also i found my answer and here it is:

$HAy[]=array('a' => $a, 'm' => $m);
foreach($HAy as $c=>$key) {
$sort_num_rec[] = $key['a'];
}
array_multisort($sort_num_rec, SORT_DESC, $HAy);
foreach ($HAy as $ay){
//do something
}

was a bit confuse in the beginning, but i figure it out using array_multisort.

You want to sort multiple arrays based on one of the array's sorting order. use array_multisort();

http://www.php.net/manual/en/function.array-multisort.php

array_multisort($m, $a);

this will sort both arrays according to the first arrays sort ordering.