Step 1: Treat same-size books as groups.
Treat each group of books as a single item. The number of ways to arrange the groups is \( 3! \) (for the three groups). Within each group, the books can be arranged in \( 5! \), \( 4! \), and \( 2! \) ways for large, medium, and small books respectively.
Step 2: Conclusion.
Thus, the total number of ways is \( 5! \times 4! \times 2! \).