You can do them in either order, both are effectively interrupts.
The Combat Challenge is an Immediate Interrupt
while the Opportunity attack is (obviously) an Opportunity Attack
.
After the first attack is done, the fighter will need to recheck to validate that the Opportunity Attack is still valid. For example, the Combat Challenge might push the enemy so that it is no longer adjacent to the fighter and then the Opportunity action would be lost.
This is all assuming that:
- The fighter is adjacent to the enemy making the ranged attack
- The fighter has the enemy marked
- The enemy is not attacking the fighter
- The fighter has not spent his Immediate Action since the end of his last turn.
- The fighter has not used an Opportunity Action during this enemies turn.