How to sort array that extracted from database in this condition?

Hi,

I’m trying to sort my search result with priority desc.

Thus, I get the data like this:

$result = mysql_query("SELECT id,status,priority,title from books
WHERE status='active' and MATCH(title) 
AGAINST ('".$keyword."' IN BOOLEAN MODE) 
order by priority desc, title asc limit $from,$limit") 
or die(mysql_error());

Then I echo my result:

while($row=mysql_fetch_array($result)){
echo "<p>".$row['title']."</p>";
}

The script works fine but I wish to have the books that having highest priority (priority=5) to be displayed randomly. The other books will display in title asc mode.

May I know is it possible to do in the mysql query?