All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad is His slave and Messenger.
The correct way according to the Sunnah in completing the rows is to complete the first row and then the next one and so forth, while standing closely shoulder-to-shoulder and foot-to-foot and leaving no gaps between one another. A new row should not be started unless the rows in front of it are full, and the places [gaps] in the rows in the front should be completed before starting a new row. This is in case men and women are separated and can not see one another.
However, if men and women can see one another (praying in one open area), then the best row for women is the last row, because it is far from men and away from the possibility of being tempted by them, and the worst row for men is the last row.
For more benefit on straightening the rows, please refer to Fataawa 88447 and 82747.