code: private static int sortAbstractLongArray(Block array, long[] buffer, AbstractType type)
      {
          int arraySize = array.getPositionCount();
          int nonNullSize = 0;
          for (int i = 0; i < arraySize; i++) {
              if (!array.isNull(i)) {
                  buffer[nonNullSize++] = type.getLong(array, i);
              }
          }
          for (int i = 1; i < nonNullSize; i++) {
              if (buffer[i - 1] > buffer[i]) {
                  Arrays.sort(buffer, 0, nonNullSize);
                  break;
              }
          }
          return nonNullSize;
      }
docs: Assumes buffer is long enough, returns count of non-null elements.