private void merge(T[] arValues, int left, int middle, int right) {
    //
    int nrTimes = (right - left) + 1;
    //
    int leftMoves = left;
    T leftValue = null;
    //
    int middleMoves = middle + 1;
    T middleValue = null;

    Vector<T> arTemp = new Vector<T>(nrTimes);

    for (int i = 0; i < nrTimes; i++) {
      this.incOperations();

      if (leftMoves <= middle) {
        leftValue = arValues[leftMoves];
      }

      if (middleMoves <= right) {
        middleValue = arValues[middleMoves];
      }

      if ((leftValue != null) && (middleValue == null)) {
        arTemp.add(i, leftValue);
        leftMoves++;
        leftValue = null;
      }
      else if ((leftValue == null) && (middleValue != null)) {
        arTemp.add(i, middleValue);
        middleMoves++;
        middleValue = null;
      }
      else if (leftValue.compareTo(middleValue) > 0) {
        arTemp.add(i, leftValue);
        leftMoves++;
        leftValue = null;
      }
      else {
        arTemp.add(i, middleValue);
        middleMoves++;
        middleValue = null;
      }

    }

    // Transfer the sorted elements to the original array.
    for (int i = 0; i < nrTimes; i++) {
      this.incOperations();
      arValues[left + i] = arTemp.get(i);
    }
  }