Another interpretation of (Genesis 9:18) "And the sons of Noah were." Rabbi Levi said: By the merit of what they did in the ark, they went out from the ark. And why? Throughout all twelve months that they spent in the ark, they were girding their loins and feeding the cattle and the beasts. And by the merit of this, they went out from the ark.
Why Noah's Sons Earned Their Exit From the Ark
Midrash Tanchuma Buber, Noach 19:2
ד"א ויהיו בני נח, אמר ר' לוי בזכות שעשו בתבה יצאו מן התבה, ולמה כל י"ב חודש שעשו בתבה היו חוגרין מתניהם וזנין הבהמה והחיה, ובזכות כן יצאו מן התבה.