Revised the qsort function. This may not be necessary since the nodes are generated in an ascending sequence.