Source:
<code>public Function<Sequence<Row>, Sequence<Row>> build( List<DimensionSpec> dimensions, List<AggregatorFactory> aggs, List<PostAggregator> postAggs ) { boolean sortingNeeded = false; if (dimensions.size() < columns.size()) { sortingNeeded = true; } final Set<String> aggAndPostAggNames = Sets.newHashSet(); for (AggregatorFactory agg : aggs) { aggAndPostAggNames.add(agg.getName()); } for (PostAggregator postAgg : postAggs) { aggAndPostAggNames.add(postAgg.getName()); } if (!sortingNeeded) { for (int i = 0; i < columns.size(); i++) { final OrderByColumnSpec columnSpec = columns.get(i); if (aggAndPostAggNames.contains(columnSpec.getDimension())) { sortingNeeded = true; break; } final ValueType columnType = getOrderByType(columnSpec, dimensions); final StringComparator naturalComparator; if (columnType == ValueType.STRING) { naturalComparator = StringComparators.LEXICOGRAPHIC; <START> } else { <END> naturalComparator = StringComparators.NUMERIC; } if (columnSpec.getDirection() != OrderByColumnSpec.Direction.ASCENDING || !columnSpec.getDimensionComparator().equals(naturalComparator) || !columnSpec.getDimension().equals(dimensions.get(i).getOutputName())) { sortingNeeded = true; break; } } } if (!sortingNeeded) { return limit == Integer.MAX_VALUE ? Functions.<Sequence<Row>>identity() : new LimitingFn(limit); } final Ordering<Row> ordering = makeComparator(dimensions, aggs, postAggs); if (limit == Integer.MAX_VALUE) { return new SortingFn(ordering); } else { return new TopNFunction(ordering, limit); } }</code><technical_language>If outputType is COMPLEX null this is true. I this is "impossible" please check for anyway</technical_language>

Target:
public Function<Sequence<Row>, Sequence<Row>> build( List<DimensionSpec> dimensions, List<AggregatorFactory> aggs, List<PostAggregator> postAggs ) { boolean sortingNeeded = false; if (dimensions.size() < columns.size()) { sortingNeeded = true; } final Set<String> aggAndPostAggNames = Sets.newHashSet(); for (AggregatorFactory agg : aggs) { aggAndPostAggNames.add(agg.getName()); } for (PostAggregator postAgg : postAggs) { aggAndPostAggNames.add(postAgg.getName()); } if (!sortingNeeded) { for (int i = 0; i < columns.size(); i++) { final OrderByColumnSpec columnSpec = columns.get(i); if (aggAndPostAggNames.contains(columnSpec.getDimension())) { sortingNeeded = true; break; } final ValueType columnType = getOrderByType(columnSpec, dimensions); final StringComparator naturalComparator; if (columnType == ValueType.STRING) { naturalComparator = StringComparators.LEXICOGRAPHIC; } else if (columnType == ValueType.LONG || columnType == ValueType.FLOAT) { naturalComparator = StringComparators.NUMERIC; } else { sortingNeeded = true; break; } if (columnSpec.getDirection() != OrderByColumnSpec.Direction.ASCENDING || !columnSpec.getDimensionComparator().equals(naturalComparator) || !columnSpec.getDimension().equals(dimensions.get(i).getOutputName())) { sortingNeeded = true; break; } } } if (!sortingNeeded) { return limit == Integer.MAX_VALUE ? Functions.<Sequence<Row>>identity() : new LimitingFn(limit); } final Ordering<Row> ordering = makeComparator(dimensions, aggs, postAggs); if (limit == Integer.MAX_VALUE) { return new SortingFn(ordering); } else { return new TopNFunction(ordering, limit); } }