We complained to the Messenger of Allah ﷺ on the day of Uhud, saying, "Messenger of Allah, digging a grave for each person is too difficult for us."The Messenger of Allah ﷺ said, "Dig, make the graves deep, dig them well, and bury two or three in a single grave."They asked, "Whom shall we put first, Messenger of Allah?"He replied, "Put first the one who knew the most of the Quran."He said, Ubayy was the third of three placed in a single grave.
أخبرنا محمد بن بشار قال حدثنا إسحق بن يوسف قال حدثنا سفيان عن أيوب عن حميد بن هلال
شكونا إلى رسول الله ﷺ يوم أحد فقلنا يا رسول الله الحفر علينا لكل إنسان شديد فقال رسول الله ﷺ احفروا وأعمقوا وأحسنوا وادفنوا الاثنين والثلاثة في قبر واحد قالوا فمن نقدم يا رسول الله قال قدموا أكثرهم قرآنا قال فكان أبي ثالث ثلاثة في قبر واحد
[Sahih]. Reported by Abu Dawud in the chapter on Funerals, section on digging the grave deep, hadith no. 3216, from the hadith of Sufyan Thawri, and by Tirmidhi, hadith no. 1713, and Ibn Majah, hadith no. 1560, from the hadith of Ayub, by the same route, and he said, hasan sahih. It is also found in Kubra, hadith no. 2137. See the following hadith.