title: Merge Sort Algorithm fail
body: <p>I wrote a merge-sort algorithm in python. It works perfectly until 10000 numbers but after 10000 it gives me segmentation fault 11. What might be the problem? Any idea about it</p>
  
  <pre><code>def merge_count(arr):
      if len(arr) &lt; 2:
          return (arr, 0)
      m = int(len(arr) / 2)
      left, l_counter = merge_count(arr[:m])
      right, r_counter = merge_count(arr[m:])
      return merge(left, right, l_counter + r_counter)
  
  
  def merge(left, right, counter):
      if len(left) * len(right) == 0:
          return (left + right, counter)
      if left[len(left) - 1] &gt; right[len(right) - 1]:
          val = left.pop(len(left) - 1)
          counter += len(right)
      else:
          val = right.pop(len(right) - 1)
      arr, counter = merge(left, right, counter)
  
      return (arr + [val], counter)
  </code></pre>