The Messenger of Allah ﷺ said, "Dig the graves well and deep, and bury two or three together, placing the one with the most knowledge of the Quran at the front."
أخبرنا إبراهيم بن يعقوب قال حدثنا مسدد قال حدثنا عبد الوارث عن أيوب عن حميد بن هلال عن أبي الدهماء
أن رسول الله ﷺ قال احفروا وأحسنوا وادفنوا الاثنين والثلاثة وقدموا أكثرهم قرآنا
[Its chain of transmission is sahih] Ibn Majah reported it in the Book of Funerals, Chapter on What Has Been Said Regarding Digging the Grave, no. 1560, from the hadith of Abdul-Warith, as mentioned before, no. 2012, and it is also found in Al-Kubra, no. 2144.