Abu Mas'ud (May Allah be pleased with him) reported:
The Messenger of Allah (ﷺ) used to gently pat our shoulders when we were standing in rows at the time of Salat and say, "Keep (the rows) straight; do not differ from each other lest your hearts should suffer from discord. Let those of you who are mature and prudent be nearer to me, and then those who are next to them."[Muslim].
App reference: Book 9, Hadith 96
Arabic/English book reference: Book 9, Hadith 1086