Another interpretation of (Genesis 6:9) "These are the generations of Noah; Noah was a righteous man." Why was he called by the name "righteous"? Since he fed the creatures of the Holy One, blessed be He, he became like his Creator, as the matter is stated (in Psalms 11:7): "For the LORD is righteous; He loves righteous deeds." And likewise Joseph: since he fed the creatures for seven years, he was called righteous, as it is stated (in Amos 2:6): "because they sold the righteous one for silver." (And because he fed the creatures for seven years, therefore he was called righteous.)
Why Noah and Joseph Were Both Called Righteous for Feeding Creatures
Midrash Tanchuma Buber, Noach 4:3
ד"א אלה תולדות נח נח איש צדיק. למה נקרא שמו צדיק, הואיל וזן את בריותיו של הקב"ה נעשה כבוראו, כענין שנאמר כי צדיק ה' צדקות אהב (תהלים יא ז), וכן יוסף הואיל וזן את הבריות שבע שנים, נקרא צדיק, שנאמר על מכרם בכסף צדיק (עמוס ב ו), (ולפי שזן את הבריות שבע שנים, לפיכך נקרא צדיק).