If I cast a sorcery spell to force the opponent to discard two cards, and he/she then casts one of those cards as an instant, would the instant apply first or would the sorcery take precedence?
Short Answer: As long as they chose to cast the instant before you chose the cards to discard, then the Instant applies (resolves) first.
Magic the gathering uses a stack for casting spells. This means that literally all spells being cast go on the stack.
Each time a player casts a spell they get priority back after the spell is cast so they can continue to put spells on the stack. If they choose to be done casting spells at that moment then they pass priority to their opponents who can add spells to the stack.
After everyone is done adding spells to the stack, it starts to resolve from the top down.
This means the last spell cast is the first spell to resolve.
So the instant would apply first because it went on the stack last and was cast in response to the sorcery.
Because of this there is almost never a time where you can cast a spell that your opponent can not react to, if they have the mana and cards to react with.
Magic is very deceptive because on the surface it seems to be an aggressive game but in truth is an extremely reactive game. Mastering timing and priority can take a long time and is one of the key points of strategy for the game.
It can be a bit confusing when first starting out but I suggest reading the comprehensive rules section
In simplest terms possible: Your opponent can cast any instants in response to your sorcery, but he'll still have to discard 2 cards if he has any.
so, if you cast mind rot, your opponent can't choose 2 instants to discard and cast them instead. He can cast instants before he chooses.
If you cast duress, your opponent can't cast the instant that you pick for him to discard. He can cast instants before he shows you his hand.
Here's how It works
Everything that the sorcery spell does happens while it's resolving. If you look at your opponents hand and choose the cards, than that would happen while it resolves. If your opponent chooses, he chooses while it resolves.
Once the spell has begun to resolve, You cannot cast any spells until the spell has finished resolving.