It is narrated from Sayyiduna Anas (may Allah be pleased with him) that the Messenger of Allah (peace and blessings be upon him) liked "the Muhajirun and the Ansar to be close to him so that they could memorise (the rulings of the religion) from him."
These are the words of al-Sahmi.
In the narration of Khalid bin Abdullah the words are: "and the Ansar in the prayer (should be close to him) so that they could acquire (the knowledge of the religion) from him."
Imam Ahmad (may Allah have mercy on him) also narrated it from Abdullah bin Bakr (may Allah have mercy on him), from Humayd (may Allah have mercy on him), like the narration of al-Khazzaz.
Related hadith on this topic