public DocumentOrderIterator(SequenceIterator base, NodeOrderComparer comparer) throws XPathException {
this.comparer = comparer;
sequence = new SequenceExtent(base);
//System.err.println("sort into document order: sequence length = " + sequence.getLength());
if (sequence.getLength()>1) {
//QuickSort.sort(this, 0, sequence.getLength()-1);
GenericSorter.quickSort(0, sequence.getLength(), this);
//GenericSorter.mergeSort(0, sequence.getLength(), this);