Sayyiduna Nu'man bin Bashir رضي الله عنه narrates that the Noble Prophet صلى الله عليه وسلم said: "Straighten your rows in prayer, otherwise Allah, the Exalted, will turn your faces."
Hadith Referenceاللؤلؤ والمرجان / كتاب الصلاة / 250
Hadith Gradingمحدثین:«صحیح»
Hadith Takhrij«صحیح، أخرجه البخاري في: 10 كتاب الأذان: 71 باب تسوية الصفوف عند الإقامة وبعدها»
Brief Explanation
Imam Ibn Hazm rahimahullah, based on the apparent meaning of these ahadith, has stated that straightening the rows is obligatory (wajib), whereas according to the majority of scholars, it is Sunnah. The purpose of keeping the rows straight is that they should stand on a single straight line, and not stand ahead or behind one another. (Waheed al-Zaman rahimahullah)