It is narrated from Sayyiduna Abdullah bin Mas'ud (may Allah be pleased with him) that the Prophet (peace and blessings be upon him) said: "Let those of you who have understanding and intelligence stand closest to me, then those who come after them, then those who come after them. Do not differ (in the rows), or your hearts will differ, and beware of the clamour of the markets."
Hadith Referenceالمعجم الكبير للطبراني / باب العين / 10005