I play Doctor and name Rats. I reveal the top 3 cards and find 1 Rats, so I trash it. Which happens first: re-ordering the other cards, or drawing my card from trashing Rats? And if the draw happens first, what do I draw? The first non-Rats card that Doctor revealed, or the first unrevealed card in my deck?
Dominion cards are always processed from the top down:
To play an Action, the player takes an Action card from his hand and lays it face-up in his play area. He announces which card he is playing and follows the instructions written on that card from top to bottom.
However, "when you trash" cards interrupt the existing Action:
Many cards in Dark Ages do something "when you trash" that card. These abilities function no matter whose turn the card is trashed on. The player that a "when you trash this" ability functions for is the player that had that card, regardless of whose card trashed the card. These abilities happen directly after the card is put into the trash, and can function in the middle of resolving effects for an Action card; for example, if a player plays Graverobber and uses it to trash a Cultist, he first draws three cards for trashing Cultist, then continues with resolving Graverobber and gains a card costing up to $8.
Therefore, you draw the card from trashing the Rats before the cards would be put back on top of your deck because Doctor has "Trash the matches." before "Put the rest back on top in any order." and the Rats trashing resolves during the "Trash the matches" section of Doctor.
Colin is right, the Dark Ages rule book says:
" If Rats is trashed, you draw a card. This happens whether it is your turn or another player's, and regardless of which player has the card that trashed Rats."
Also from the Original rule book:
“Reveal” – when a player reveals a card, he shows a card to all players and then returns it to wherever it came from (unless instructed specifically to put it elsewhere)
So revealed cards are not "part of the deck" else how could they be "returned" to it?