Simple, 2 Pair Ace's and 7s beat Jacks and 8s, It is always decided on the Highest pair first and if you both have the same top pair then it falls to the second pair to decide who wins.
It is the same with flushes, If there is a 5 Card Flush on the Table and players at showdown declare the Flush then it is decided on the card Value, if each person has a Card in the same suit then it is the highest Value card if that card Plays.
Meaning if you have A,K, J,,9, 6, on the Table all Hearts and the 2 or 3 players at Showdown each Have a Heart in their hand It is only a Split pot if no one can beat the 6 but if you have one player with a higher card than the 6 then it's his card that plays in place of the 6 and wins the pot outright.
Highest card Value playing takes the Pot.