If my opponent casts Head Games at me, and I put my hand on my library, can I rearrange my library before showing it to him?
No. Unless an instruction tells you to shuffle your library, and only when that instruction tells you to, you may not shuffle your library. To do so at any other time could be, at a minimum, a Procedural Error.
You must follow the instructions of the card as stated. In this case, putting the cards from your hand on top of your library, and then the player of the Head Games performs a search for that many cards (which become your new hand). Then, after all this, you shuffle your library.
But until that point, you cannot affect the order of your library in any way, shape or form.