Fiqh-us-Sunnah Volume 4, Funerals and Dhikr, Fiqh 4.044B.
If there are a number of bodies, including both male and female, they should be placed in separate rows, between the imam and the direction of the Ka’abah, with the best among them nearer to the imam, and a single funeral prayer may be offered for all of them.
If the deceased include both male and female, a separate prayer for each may be offered. But it is also permissible to offer one prayer for all of them at once. In such a case the male should be placed immediately before the Imam and then the female in the direction of the Qiblah.
It is reported by Nafi’ from Ibn ‘Umar that he offered a funeral prayer for nine of the deceased, males and females. He placed the males closest to the imam and then the females in the direction of the Qiblah. He placed all of them in one row. The funeral of Umm Kulthum, daughter of ‘Ali and the wife of ‘Umar, and her son called Zaid, was led by Sa’id ibn al-‘As, and among the people attending this funeral were Ibn Abbas, Abu Hurairah, Abu Sa’id and Abu Qatadah. The little boy was placed before the imam. A man said: “I do not like this arrangement, and looked towards Ibn ‘Abbas, Abu Hurairah, Abu Sa’id and Abu Qatadah, and said to them: “What is this?” They replied: “This is the sunnah of the Prophet, peace be upon him,. This was narrated by Nasa’i and Al-Baihaqi, and Al-Hafiz says its chain of authorities is sound.
Another hadith says that if a funeral prayer is offered for a child together with a woman, the boy should be placed nearer the imam and the woman next to it in the direction of the Qiblah. And if there are men, women and children, then the children should be placed next to the men.