English : Vol. 1, Book 5, Hadith 976
Grading supplied with this record: Sahih (Darussalam)
Narration text is preserved in its supplied Arabic and English. Translated interfaces and reading guides do not add narration translations in other languages.
لاَ تَخْتَلِفُوا فَتَخْتَلِفَ قُلُوبُكُمْ لِيَلِيَنِي مِنْكُمْ أُولُو الأَحْلاَمِ وَالنُّهَى ثُمَّ الَّذِينَ يَلُونَهُمْ ثُمَّ الَّذِينَ يَلُونَهُمْ "
It was narrated that Abu Mas'ud Al-Ansari said:
"The Messenger of Allah (ﷺ) used to gently pat our shoulders (to make sure the row was straight) at the time of prayer, saying: "Keep (the rows) straight, do not differ from one another lest your hearts should suffer from discord. Let those who are forbearing and wise stand closest to me, then those who are next to them, then those who are next to them.'"
Full reference and source
English : Vol. 1, Book 5, Hadith 976 Arabic : Book 5, Hadith 1029
View source on Sunnah.com (opens in a new tab)