The spell or permanent's owner chooses whether to put it on the top or bottom of their library. If multiple cards are put into the library this way (such as when the spell targets a melded permanent), that spell or permanent's owner puts all the cards on top or all the cards on the bottom. They put them in whatever order they wish, and they do not need to reveal the order.