The Messenger of Allah ﷺ said, "May Allah have mercy on Lut. He truly had a mighty support to turn to. And had I remained in prison as long as Yusuf remained, I would have answered the one who called me."
قال رسول الله ﷺ يرحم الله لوطا لقد كان يأوي إلى ركن شديد ولو لبثت في السجن ما لبث يوسف لأجبت الداعي
Its isnad is sahih. Bukhari related it in the tafsir and in the hadiths of the prophets from Ahmad bin Salih, and in the tafsir from Saeed bin Talid. Muslim related it in the faith and in the virtues from Harmala bin Yahya. Ibn Majah related it in the tribulations from Harmala bin Yahya and Yunus bin Abdul-Ala.