}
public Expression compile(Executable exec) throws TransformerConfigurationException {
SortKeyDefinition[] sortKeys = makeSortKeys();
if (select != null) {
SortExpression sortedSequence = new SortExpression(select, sortKeys);
ExpressionTool.makeParentReferences(sortedSequence);
return sortedSequence;
} else {
Block body = new Block();
compileChildren(exec, body, true);
try {
SortExpression sortedSequence = new SortExpression(body.simplify(getStaticContext()), sortKeys);
ExpressionTool.makeParentReferences(sortedSequence);
return sortedSequence;
} catch (XPathException e) {
compileError(e);
return null;