private static void setOrderOnTestPartitions(LinkedList<List<IntWritable>> partition,
      PTFInvocationSpec.Order order) {
    LinkedList<List<IntWritable>> notNulls = partition.stream()
        .filter(r -> r.get(ORDER_BY_COL) != null).collect(toCollection(LinkedList::new));
    List<List<IntWritable>> nulls =
        partition.stream().filter(r -> r.get(ORDER_BY_COL) == null).collect(toList());

    boolean isAscCurrently =
        notNulls.getFirst().get(ORDER_BY_COL).get() < notNulls.getLast().get(ORDER_BY_COL).get();

    if ((ASC.equals(order) && !isAscCurrently) || (DESC.equals(order) && isAscCurrently)) {
      Collections.reverse(notNulls);
      partition.clear();
      partition.addAll(notNulls);
      partition.addAll(nulls);
    }
  }
Reverses order on actual data if needed, based on order parameter.
@param order
ql/src/test/org/apache/hadoop/hive/ql/udf/ptf/TestBoundaryCache.java