i made this sample multi dimensional array sort to someone who needed to read lines from a text file instead of using sql - order by statement.
the idea is to take the key and sort(order) the specific column and then order the entire of the array as the selected column asort returned.
<?php
$foo = array();
$sort_by = SORT_REGULAR;
$order_by = 1;
$line_of_text[1] = 'a1name|f2age|h3rank|jcolor';
$line_of_text[2] = 'b1name|d2age|i3rank|k4color';
$line_of_text[0] = 'c1name|e2age|g3rank|l4color';
for ($x=0; $x<=2; $x++)
{
$line = explode('|',$line_of_text[$x]);
for ($i=0; $i<=3; $i++) {
$foo[$i][$x] = $line[$i];
}
}
$a = $foo[$order_by];
asort($a, $sort_by);
echo "<table cellpudding=0 cellspacing=0 border=1>\n";
echo "<tr>\n";
echo "<td>key</td>\n";
echo "<td>name</td>\n";
echo "<td>age</td>\n";
echo "<td>rank</td>\n";
echo "<td>color</td>\n";
echo "</tr>\n";
foreach ($a as $k => $v) {
echo "<tr>\n";
echo "<td>$k</td>\n";
echo "<td>".$foo[0][$k]."</td>\n";
echo "<td>".$foo[1][$k]."</td>\n";
echo "<td>".$foo[2][$k]."</td>\n";
echo "<td>".$foo[3][$k]."</td>\n";
echo "</tr>\n";
}
echo "</table>\n";
?>