Straightening the rows before prayer is obligatory. The Prophet ﷺ would not commence the prayer until he observed the rows and ensured that shoulders and ankles were aligned. Once the rows were correctly straightened, he would begin the prayer, emphasising its importance in congregational worship.
Is straightening the rows before the prayer obligatory or recommended?
It is obligatory to straighten the rows. The Messenger ﷺ would not begin the prayer until looking at the rows and ordering that the shoulders and ankles be aligned in their correct positions. Thereon after if the rows had been correctly straightened he ﷺ would begin the prayer.