/**
   * Returns an int to int hash map with old row numbers mapped to new row numbers, which defines a
   * sorted order for this column
   *
   * @param validRows row numbers from which the sorted order is retrieved.
   */
  public VIntIntHashMap getNewOrder(int[] validRows) {

    Object[] sortedValues = getValuesInRange(validRows[0], validRows[validRows.length - 1]);

    Object[] rawValues = getValues(validRows);

    // will hold the new order, the returned value.
    int[] newOrder = new int[validRows.length];

    // a flag array. occupiedIndices[j] == true mean that the row number
    // stored at validRows[j] was already mapped to a value in tempMap
    boolean[] ocuupiedIndices = new boolean[validRows.length];

    // for each valid row validRows[i]
    for (int i = 0; i < validRows.length; i++) {

      // finding the index of its mapped Object in values

      int newRow = Arrays.binarySearch(sortedValues, rawValues[i]);

      // because binarySearch can return the same index for items that are identical
      // checking for this option too.
      if (ocuupiedIndices[newRow]) {

        // if newRow index was already used - finding an alternative index
        newRow = getNewRow(rawValues[i], sortedValues, newRow, ocuupiedIndices);

        // marking the associated flag as true
      }
      ocuupiedIndices[newRow] = true;

      newOrder[newRow] = validRows[i];
    } // end of for
    return VHashService.getMappedOrder(validRows, newOrder);
  }