currentPlan = currentPlans.pop();
// get the physical operator for sort
POSort sort;
if (s.getUserFunc() == null) {
sort = new POSort(new OperatorKey(scope, nodeGen
.getNextNodeId(scope)), s.getRequestedParallelism(), null,
sortPlans, s.getAscendingCols(), null);
} else {
POUserComparisonFunc comparator = new POUserComparisonFunc(new OperatorKey(
scope, nodeGen.getNextNodeId(scope)), s
.getRequestedParallelism(), null, s.getUserFunc());
sort = new POSort(new OperatorKey(scope, nodeGen
.getNextNodeId(scope)), s.getRequestedParallelism(), null,
sortPlans, s.getAscendingCols(), comparator);
}
sort.setAlias(s.getAlias());
sort.setLimit(s.getLimit());