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);
}
iterator = sequence.iterate(null);