code: public void sort(DTMIterator v, Vector keys, XPathContext support)
            throws javax.xml.transform.TransformerException
    {
  
      m_keys = keys;
  
      // QuickSort2(v, 0, v.size() - 1 );
      int n = v.getLength();
  
      // %OPT% Change mergesort to just take a DTMIterator?
      // We would also have to adapt DTMIterator to have the function 
      // of NodeCompareElem.
      
      // Create a vector of node compare elements
      // based on the input vector of nodes
      Vector nodes = new Vector();
  
      for (int i = 0; i < n; i++)
      {
        NodeCompareElem elem = new NodeCompareElem(v.item(i));
  
        nodes.addElement(elem);
      }
  
      Vector scratchVector = new Vector();
  
      mergesort(nodes, scratchVector, 0, n - 1, support);
  
      // return sorted vector of nodes
      for (int i = 0; i < n; i++)
      {
        v.setItem(((NodeCompareElem) nodes.elementAt(i)).m_node, i);
      }
      v.setCurrentPos(0);
  
      // old code...
      //NodeVector scratchVector = new NodeVector(n);
      //mergesort(v, scratchVector, 0, n - 1, support);
    }
docs: Given a vector of nodes, sort each node according to
  the criteria in the keys.
  @param v an vector of Nodes.
  @param keys a vector of NodeSortKeys.
  @param support XPath context to use
  
  @throws javax.xml.transform.TransformerException