The best way to cheer yourself is to try to cheer somebody else up.

Twain - cheer somebody else up - wist_info quote

Mark Twain (1835-1910) American writer [pseud. of Samuel Clemens]
Mark Twain’s Notebook [ed. Paine (1935)]

Often given as "The best way to cheer yourself up is to try to cheer somebody else up." More discussion here.