In one of the most influential books in the field of advanced analytics in baseball The Book: Playing the Percentages written by Tom Tango, Mitchel Lichtman, and Andrew Dolphin, one of the topics covered was optimal lineup construction.
Your three best hitters should bat somewhere in the #1, #2, and #4 slots. Your fourth- and fifth-best hitters should occupy the #3 and #5 slots. The #1 and #2 slots will have players with more walks than those in the #4 and #5 slots. From slot #6 through #9, put the players in descending order of quality.