yeah, just do a query that grabs the col name that you want to sort by, and the id. Then do a while statement that increments the rank, and do an update query.
$result = mysql_query("SELECT colname, id FROM table_name ORDER BY colname");
$i = 1;
while( $row = mysql_fetch_array($result) )
{
mysql_query("UPDATE table_name SET rank='$i' WHERE id='$row[id]'");
$i++;
}