It is narrated from Sayyiduna Jabir bin Abdullah (may Allah be pleased with him) that the Messenger of Allah (peace and blessings be upon him) said: "Straightening the row is part of the completion of the prayer."
Hadith Referenceالمعجم الكبير للطبراني / باب الجيم / 1731