// determine the best order and the transformation is returned. This
// transform is applied to the unsubstituted pattern (which will be
// substituted as part of evaluation.
if ( ! peek.hasNext() )
throw new ARQInternalErrorException("Peek iterator is already empty") ;
BasicPattern pattern2 = Substitute.substitute(pattern, peek.peek() ) ;
// Calculate the reordering based on the substituted pattern.
ReorderProc proc = transform.reorderIndexes(pattern2) ;
// Then reorder original patten