Hi all

im trying to do a sort on a array of data, but i cant seem to figuere it out.

This is my function i get the data with (there is prolly an easier way, but it works)
Code:
function listitems($category,$sortby,$sort) {
	$q = "SELECT * FROM ".TBL_ITEMS." WHERE type = '$category' ORDER BY ".$sortby." ".$sort."";
	$result = mysql_query($q, $this->connection);
	$num = mysql_numrows($result); 
	$itemList = array();
	$i=0;
	while ($i < $num) {
		$iid=mysql_result($result,$i,"iid");
		$name=mysql_result($result,$i,"name");
		$a_atk=mysql_result($result,$i,"a_atk");
		$a_def=mysql_result($result,$i,"a_def");
		$a_spd=mysql_result($result,$i,"a_spd");
		$a_int=mysql_result($result,$i,"a_int");
		$r_lvl=mysql_result($result,$i,"reqlevel");
		$p_buy=mysql_result($result,$i,"p_buy");
		$a_total = $a_atk + $a_def + $a_spd;
		$i_path='IMG/items/'.$iid.'.png';
		// ADD TO ARRAY
		$itemList[$i] = array('iid' => $iid, 'name' => $name, 'a_atk' => $a_atk,'a_def' => $a_def, 'a_spd' => $a_spd,'a_int' => $a_int,'r_lvl' => $r_lvl,'p_buy' => $p_buy,'p_sale' => $p_sale,'a_total' => $a_total,'i_path' => $i_path);
		++$i;
	}
	return $itemList;
}
now i can sort with that on all columns except for the a_total since i made that after the query.

I've tried numerous sort function i could find on help pages, but none of em worked and im a bit stuck. And what i could read on php.net i couldnt figuere out how to sort a list of arrays based on a "column" inside a subarray.

most of the time a pointer in the right direction would help too, its prolly not as hard as i currently think it is.
Any help would be appriciated very much.