Sunan an-Nasa'i, Book 4, Hadith 9 (In-Book) ⓘ
It was narrated that 'Abdullah bin Abi Qais said: "I asked 'Aishah: 'How did the Messenger of Allah sleep while he was Junub? Did he perform Ghusl before sleeping or sleep before performing Ghusl?' She said: 'He did both. Sometimes he would perform Ghusl then sleep, and sometimes he would perform Wudu' then sleep.'"
أَخْبَرَنَا شُعَيْبُ بْنُ يُوسُفَ، قَالَ حَدَّثَنَا عَبْدُ الرَّحْمَنِ بْنُ مَهْدِيٍّ، عَنْ مُعَاوِيَةَ بْنِ صَالِحٍ، عَنْ عَبْدِ اللَّهِ بْنِ أَبِي قَيْسٍ، قَالَ سَأَلْتُ عَائِشَةَ كَيْفَ كَانَ نَوْمُ رَسُولِ اللَّهِ صلى الله عليه وسلم فِي الْجَنَابَةِ أَيَغْتَسِلُ قَبْلَ أَنْ يَنَامَ أَوْ يَنَامُ قَبْلَ أَنْ يَغْتَسِلَ قَالَتْ كُلُّ ذَلِكَ قَدْ كَانَ يَفْعَلُ رُبَّمَا اغْتَسَلَ فَنَامَ وَرُبَّمَا تَوَضَّأَ فَنَامَ .
also referenced under: Hadith 404 (Reference) & Volume 1, Book 4, Hadith 404 (DarusSalam)