-----start code-----
$sortterm;
get_locations();
function cmp ($a, $b) { GLOBAL $sortterm; return strcmp($a[$sortterm], $b[$sortterm]); }
function get_locations(){ GLOBAL $sortterm; $i="1"; while(($row=mysql_fetch_object($result))){ $locs[$i][loc_id]=$row->loc_id; $locs[$i][fac]=$row->fac; $locs[$i++][field]=$row->field; }
reset($locs);
$sortterm="field";
usort($locs, "cmp");
reset($locs);
$sortterm="fac";
usort($locs, "cmp");
reset($locs);
while (list ($key, $value) = each ($locs)) {
echo $locs[$key][loc_id].", ".$locs[$key][fac].", ".$locs[$key][field]."<br>\n";
}
}
-----end code-----
Here is how it comes out when run: 12, Johnson County Community College, C 11, Johnson County Community College, B 13, Johnson County Community College, D 14, Johnson County Community College, E 10, Johnson County Community College, A 8, Johnson County Girls Athletic Assoc, D 6, Johnson County Girls Athletic Assoc, B 7, Johnson County Girls Athletic Assoc, C 5, Johnson County Girls Athletic Assoc, A 9, Shawnee Civic Center, 1 1, Tomahawk Sports Dome, 1 2, Tomahawk Sports Dome, 2 3, Tomahawk Sports Dome, 3 4, Tomahawk Sports Dome, 4
As you can see, the fac is sorted correctly, but the field isn't.
Thanks Steve
-- This message has been scanned for viruses and dangerous content by the MailScanner at ow5, and is believed to be clean.
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php