title: Why my merge sort implementation give correct result with list but give different (wrong) result when using on numpy array?
body: <p>Here is my implementation on Python</p>
  <pre><code>def merge(L, R, A):
      len_L = len(L)
      len_R = len(R)
  
      i = 0 # index for left array L
      j = 0 # index for right array R
      k = 0 # index for main array A
  
      # replace element in main array A with smaller value from either L or R
      while (i &lt; len_L and j &lt; len_R):
          if L[i] &lt; R[j]:
              A[k] = L[i]
              i+=1
          else:
              A[k] = R[j]
              j+=1
          k+=1
  
      # replace the rest of main array A with the remianing element from either L or R
      while i &lt; len_L:
          A[k] = L[i]
          i+=1
          k+=1
      while j &lt; len_R:
          A[k] = R[j]
          j+=1
          k+=1
  
  def merge_sort(A):
      if len(A) &gt; 1: # if the element is still dividable (length &gt; 1)
          mid_point = len(A) // 2
  
          L = A[:mid_point]
          R = A[mid_point:]
          
  
          merge_sort(L) 
          merge_sort(R)
          merge(L, R, A)
  
  </code></pre>
  <p>when I run this code snippet</p>
  <pre><code>import numpy as np
  np.random.seed(42)
  sample_array = np.arange(21)
  np.random.shuffle(sample_array)
  print('Unsorted array:', sample_array)
  merge_sort(sample_array)
  print('Sorted array:', sample_array)
  </code></pre>
  <p>I got this result</p>
  <pre><code>Unsorted array: [ 0 17 15  1  8  5 11  3 18 16 13  2  9 20  4 12  7 10 14 19  6]
  Sorted array: [0 1 1 1 2 2 2 2 2 2 2 2 4 4 4 6 6 6 6 6 6]
  </code></pre>
  <p>I thought that my implementation is wrong, but in the end I tried to convert it to the list first</p>
  <pre><code>import numpy as np
  np.random.seed(42)
  sample_array = list(np.arange(21))
  np.random.shuffle(sample_array)
  print('Unsorted array:', sample_array)
  merge_sort(sample_array)
  print('Sorted array:', sample_array)
  </code></pre>
  <p>and suddenly my code works as expected</p>
  <pre><code>Unsorted array: [0, 17, 15, 1, 8, 5, 11, 3, 18, 16, 13, 2, 9, 20, 4, 12, 7, 10, 14, 19, 6]
  Sorted array: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
  </code></pre>
  <p>I wonder what causes this behaviour, I tried to debug a little bit but got no luck. Anyone can enlighten me?</p>