Billy Wilder wrote everything he directed and won three Academy Awards for screenwriting. He worked in two long partnerships, first with Charles Brackett and later with I A L Diamond, and considered writing the primary job with directing as protection of the script.
His rule was that the audience should be two steps ahead of one character and one step behind another, which keeps them working. Some Like It Hot’s final line was a placeholder nobody expected to keep, and it is now one of the most famous endings in comedy.
Sunset Boulevard, Double Indemnity and The Apartment all begin near the end and work backward, which he used to remove suspense so the audience could watch for how instead of what.