Sorting stage elements to keep subgraphs on the back.