pseudo code would be:
if (most viewed >= most discussed) display most viewed;
else if (most discsd >= most viewed) display most discsd;
else if (most viewed => high rate) display most viewed;
else if (most discsd >= high rate) display most viewed;
something like that, but that should set you working towards the right direction.