Sort category list

Is there a way to sort the category list in the left sidebar by category name rather than category id?
Thanks
Bob
Thanks
Bob
function getCategoriesMenuOptions(){
$sql = "select p.product_id, pc.category_id, pc.category_name, count(*) as num from products p inner join product_categories pc on p.product_categories rlike concat('[[:<:]]',pc.category_id,'[[:>:]]') group by pc.category_id";
$res = mysql_query($sql, df_db());
$out = array();
while ( $row = mysql_fetch_assoc($res) ) $out[] = $row;
return $out;
}
select p.product_id, pc.category_id, pc.category_name, count(*) as num from products p inner join product_categories pc on p.product_categories rlike concat('[[:<:]]',pc.category_id,'[[:>:]]') order by pc.category_name group by pc.category_id
select p.product_id, pc.category_id, pc.category_name, count(*) as num from products p inner join product_categories pc on p.product_categories rlike concat('[[:<:]]',pc.category_id,'[[:>:]]') group by pc.category_name