//Check if we can speed up the processing of the "order by" clause.
fastOrderBy = !(in instanceof DeferredFunctionCall) && in.isPersistentSet() && checkOrderSpecs(in);
//PreorderedValueSequence applies the order specs to all items
//in one single processing step
if (fastOrderBy) {
in = new PreorderedValueSequence(orderSpecs, in.toNodeSet(), getExpressionId());
}
//Otherwise, if there's an order by clause, wrap the result into
//an OrderedValueSequence. OrderedValueSequence will compute
//order expressions for every item when it is added to the result sequence.
if (resultSequence == null) {