title: How to convert java merge sort algo to cpp
body: <p><strong>Problem</strong></p>
  <p>I have a source code in Java for sorting array elements using the <code>merge sort</code> algorithm. The principle uses a loop to compare an element in the array with the element in the next index in the array. If the earlier is bigger than the later then the numbers are swapped logically to <code>reassign</code> the array elements in the indices.
  My problem is that the Java algo works but the C++ algo does not. The logic is the same, what am I doing wrong....</p>
  <p><strong>Code</strong></p>
  <p><code>Working Java Code</code></p>
  <pre><code>static void sort(int[] arr) {
      for (int i = 0; i &lt; arr.length; i++) {
          for (int j = i + 1; j &lt; arr.length; j++) {
              if (arr[i] &gt; arr[j]) {
                  int temp = arr[i];
                  arr[i] = arr[j];
                  arr[j] = temp;
              }
          }
      }
  }    
  </code></pre>
  <p><strong>C++ Code built on the same merge sort pseudocode as the Java Source code but fails to work</strong></p>
  <pre><code>void sorting(int d[]) {
      for (int i = 0; i &lt; sizeof(d); i++) {
          for (int j = i + 1; j &lt; sizeof(d); j++) {
              if (d[i] &gt; d[j]) {
                  int temp = d[i];
                  d[i] = d[j];
                  d[j] = temp;
              }
          }
      }
  }
  </code></pre>
  <p><strong>Input Format</strong></p>
  <p>Both methods got parameters from arrays initialized to a fixed size and then a loop was used to get input from user and asign to the array, the user has to enter the size of the array first.</p>
  <p><strong>Reliability of the merge sort algo in other languages</strong></p>
  <p>I have applied the mergesort pseudocode in JavaScript, Python and C# and they all worked. I do not know why C++ would be an exception, please help...</p>