$result = mysql_query("SELECT FROM table WHERE `pid`=0 ORDER BY `priority` ASC") or die(mysql_error());
while($row = mysql_fetch_assoc($result))
{
echo $row['title_ru'] . "<br/>";
$res = mysql_query("SELECT FROM table WHERE `pid`={$row['id']} ORDER BY `pid` ASC, `priority` ASC") or die(mysql_error());
while($r = mysql_fetch_assoc($res))
echo $r['title_ru'] . "<br/>";
}