@Udf
  public <T extends Comparable<? super T>> List<T> arraySortWithDirection(@UdfParameter(
      description = "The array to sort") final List<T> input,
      @UdfParameter(
          description = "Marks the end of the series (inclusive)") final String direction) {
    if (input == null || direction == null) {
      return null;
    }
    if (SORT_DIRECTION_ASC.contains(direction.toUpperCase())) {
      input.sort(nullsLast(naturalOrder()));
    } else if (SORT_DIRECTION_DESC.contains(direction.toUpperCase())) {
      input.sort(nullsLast(Collections.reverseOrder()));
    } else {
      return null;
    }
    return input;
  }
@Test
  public void shouldReturnNullWithNullSortDirection() {
    final List<Integer> input = Arrays.asList(1, 3, -2);
    final List<Integer> output = udf.arraySortWithDirection(input, null);
    assertThat(output, is(nullValue()));
  }