Sunan Ibn Majah, Book 5, Hadith 199 (Ibn Majah 1001)
It was narrated that Jabir bin ‘Abdullah said:
“The Messenger of Allah (ﷺ) said: ‘The best rows for men are the front rows and the worst rows are the back rows, and the best rows for women are the back rows and the worst are the front rows.’”