code: public DTMIterator sortNodes(
            XPathContext xctxt, Vector keys, DTMIterator sourceNodes)
              throws TransformerException
    {
  
      NodeSorter sorter = new NodeSorter(xctxt);
      sourceNodes.setShouldCacheNodes(true);
      sourceNodes.runTo(-1);
      xctxt.pushContextNodeList(sourceNodes);
  
      try
      {
        sorter.sort(sourceNodes, keys, xctxt);
        sourceNodes.setCurrentPos(0);
      }
      finally
      {
        xctxt.popContextNodeList();
      }
  
      return sourceNodes;
    }
docs: Sort given nodes
  
  
  @param xctxt The XPath runtime state for the sort.
  @param keys Vector of sort keyx
  @param sourceNodes Iterator of nodes to sort
  
  @return iterator of sorted nodes
  
  @throws TransformerException