Abu Masud Uqba bin Amr reported,

The Messenger of Allah ﷺ used to straighten our shoulders during the prayer and say, "Do not differ among yourselves, lest your hearts differ. Let those of you who are mature and possess understanding stand directly behind me, then those who follow them, then those who follow them."

Ibn Majah 976

Sahih

حدثنا محمد بن الصباح أنبأنا سفيان بن عيينة عن الأعمش عن عمارة بن عمير عن أبي معمر

عن أبي مسعود الأنصاري قال

كان رسول الله ﷺ يمسح مناكبنا في الصلاة ويقول لا تختلفوا فتختلف قلوبكم ليليني منكم أولوا الأحلام والنهى ثم الذين يلونهم ثم الذين يلونهم

ابن ماجه 976صحيح
Contents
Reference
Commentary
Ayat
Collection
Sunan Ibn Majah
Book
Establishing prayer and the sunnah regarding it
Chapter
Those who should stand closest to the imam
Numbering
Darussalam 976
Ibn Majah 976