Baseball Eastern Division

How do they decide which team plays which team in the Baseball playoffs.?
I know the teams the get to the playoffs are the three winners of the eastern, central, and western divisions plus the wild card team which has the next highest record overall, but how do they decide who plays whom? Does the team with the best record play the wild card or what?
The three division champions per league are seeded 1-2-3 based upon seasonal record. On-paper tiebreakers exist if necessary. The wildcard team is seeded 4 regardless of record.
Teams are then paired 1-4 and 2-3 — with one exception. If the wildcard team is from the same division as the 1 seed, the pairings are 1-3 and 2-4. Game 1 homefield in the Division Series (2-2-1, best of five format) goes to the 1 and 2 seeds.
Phillies Clinch 2009 Eastern Division Championship “with Harry Kalas”