Abdullah bin Abu Qays reported,

I asked Ayesha about the witr prayer of the Messenger of Allah ﷺ, and she mentioned the hadith.I then asked, "What did he do when he was in a state of major ritual impurity? Would he bathe before sleeping, or sleep before bathing?"She replied, "He did both. Sometimes he would bathe and then sleep, and sometimes he would perform ablution and then sleep."I said, "Praise be to Allah, who made the matter accommodating."

Azami 1500

Sahih

عن عبد الله بن أبي قيس قال

سألت عائشة عن وتر رسول الله ﷺ. فذكر الحديث قلت: كيف كان يصنع في الجنابة؟ أكان يغتسل قبل أن ينام أم ينام قبل أن يغتسل؟ قالت: كل ذلك قد كان يفعل. ربما اغتسل فنام، وربما توضأ فنام قلت: الحمد لله الذي جعل في الأمر سعة.

الأعظمي 1500صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Ghusl
Section
Ghusl for janaba before and after sleep
Numbering
Jami al-Kamil 1500 (2nd edition)
Azami 1500