Solution:
Rearrange the children in the back row into order, and rearrange the front row in the same way, so that each child stays in front of the same child in the back row. Denote heights in the back row by ai and heights in the front row by bi. So we have a1≤a2≤…≤an, and ai>bi for i=1,2,…,n.
Now if i<j, but bi>bj, then we may swap bi and bj and still have each child taller than the child in front of him. For bi<ai≤aj, and bj<bi<ai. By repeated swaps we can get the front row into height order. [For example, identify the shortest child and swap him to the first position, then the next shortest and so on.]