Answered by Shaykh Faraz Rabbani
A Sheikh said that it is wrong that people line up from the left to right of the rows. Rather, he said, it is established from Hadith that thee is most reward directly behind the Imam and then to the right and then to the left. Therefore one form each row starting from the centre and then adding on to the right until there is no more space and then adding to the left from centre.
In the Hanafi school, it is recommended to stand as close to the imam as possible. This is principle one.
It is also recommended to stand to the right of the imam. This is principle two.
Principle one is given precedence to principle two, because of the recommendation transmitted in the sunna to keep lines even. Therefore:
If the line is even on both sides of the imam, then it is best to be on the right.
But if the right is more full, then there is more reward (because principle one) to join on the left.