The Messenger of Allah ﷺ said, "Complete the first row, then the one behind it, and if there must be any shortfall, let it be in the last row."
حدثنا محمد بن بكر عن سعيد عن قتادة
أن رسول الله ﷺ قال أتموا الصف الأول ثم الذي يليه فإن كان نقصا فليكن في الصف المؤخر
Its isnad is sahih. This hadith has already appeared at the beginning of the Musnad of Abu Hurairah. It is also found in Abu Dawud 671, in the chapter on prayer, straightening the rows, and in Nasai 2/93, in the chapter on leadership in prayer, the last row, and in Ibn Hibban number 390 of his sources, and in Bayhaqi 3/102, and in Baghawi's Sharh al-Sunnah 3/374.