It is preferred for one person to stand to the right of the imam and for a “group of two (or more)” to stand behind the imam.
Jabir reports: “The Prophet stood to pray and I came and stood on his left. He took me by my hand [and led me] around him until I stood on his right. Then, Jabir ibn Sakhr came and stood on the left of the Messenger of Allah sallallahu alehi wasallam. He took both of us by our hands and pushed us back until we stood behind him.” This is related by Muslim and Abu Dawud.
If a woman is present with the group, then she is to stand in a row by herself behind the men and she is not to join them in their rows. If she did not stand in a separate row, her salah will still be valid according to the opinion of majority. Anas said: “An orphan and I prayed behind the Messenger of Allah in our house and my mother prayed behind us.” In another version it is stated: “He put me and the orphan in a row behind him and the woman behind us.” This is related by al-Bukhari and Muslim.