code: public static long[] getSortedDistinct(long[] values) {
          if (values.length == 0)
              return values;
          Arrays.sort(values);
          int shift = 0;
          int i = 0;
          while (i + shift + 1 < values.length)
              if (values[i + shift] == values[i + shift + 1])
                  ++shift;
              else {
                  values[i] = values[i + shift];
                  ++i;
              }
          values[i] = values[i + shift];
          return Arrays.copyOf(values, i + 1);
      }
docs: Sort array & return array with removed repetitive values.
  
  @param values input array (this method will quickSort this array)
  @return sorted array of distinct values