code: public static int[] getOrder(int[] values, int[] indices, boolean descending) {
          // Create an index series:
          Integer[] opIndices = ArrayUtils.toObject(indices);
  
          // Sort indices:
          Arrays.sort(opIndices, new Comparator<Integer>() {
              @Override
              public int compare(Integer o1, Integer o2) {
                  if (descending) {
                      return Double.compare(values[o2], values[o1]);
                  } else {
                      return Double.compare(values[o1], values[o2]);
                  }
              }
          });
  
          return ArrayUtils.toPrimitive(opIndices);
      }
docs: Get the order of the specified elements in descending or ascending order.
  
  @param values A vector of integer values.
  @param indices The indices which will be considered for ordering.
  @param descending Flag indicating if we go descending or not.
  @return A vector of indices sorted in the provided order.