"The Messenger of Allah ﷺ used to gently pat our shoulders (to make sure the row was straight) at the time of prayer, and he would say: 'Keep (the rows) straight; do not differ from one another lest your hearts should suffer from discord. Let those who are mature and wise stand closest to me, then those who are next to them, then those who are next to them."' (Using translation from Nasāʾī 812)
عَنِ النَّبِيِّ ﷺ قَالَ لِيَلِيَنِّي مِنْكُمْ أُولُو الْأَحْلَامِ وَالنُّهَى ثُمَّ الَّذِينَ يَلُونَهُمْ ثُمَّ الَّذِينَ يَلُونَهُمْ وَلَا تَخْتَلِفُوا فَتَخْتَلِفَ قُلُوبُكُمْ وَإِيَّاكُمْ وَهَوْشَاتِ الْأَسْوَاقِ