(28) باب تَسْوِيَةِ الصُّفُوفِ وَإِقَامَتِهَا وَفَضْلِ الأَوَّلِ فَالأَوَّلِ مِنْهَا وَالاِزْدِحَامِ عَلَى الصَّفِّ الأَوَّلِ وَالْمُسَابَقَةِ إِلَيْهَا وَتَقْدِيمِ أُولِي الْفَضْلِ وَتَقْرِيبِهِمْ مِنَ الإِمَامِ
It was narrated from Abu Huraira that the Messenger of Allah (ﷺ) said:
The best rows for men are the first rows, and the worst ones the last ones, and the best rows for women are the last ones and the worst ones for them are the first ones.
Reference: Sahih Muslim 440 a
In-book reference: Book 4, Hadith 147
USC-MSA web (English) reference(deprecated numbering scheme): Book 4, Hadith 881