For pinch hitting when needing contact, OBP is used.
For pinch hitting when needing power, SLG is used
For other, we order by AVG and then start 6 players down since players with better averages are probably going to be wanted later in close and needing contact or power situations. Once all players below the top 6 are used, it starts with the 5th best AVG and works its way up until either all players have been used or there are no more spots left.
For each pitcher type, historical averages are used to modify the stats of players in determining their order. I.E. A RHB will do better against a LHP than a RHP.