title: what's wrong with this merge sort python code?
body: <p>Here is the code for merge sort.. The code works very well and sorts the numbers. But if we go larger data that has to be sorted, something goes wrong. The data to be sorted contains numbers which are not repeated. But after sorting , there are certain numbers which gets repeated many times. I dont understand why is that.. And this happens when i give a dataset of 100000 numbers. when smaller data is to be sorted, the code works very well.</p>
  
  <pre><code>def mergeSort(alist):
      if len(alist)&gt;1:
          mid = len(alist)/2
          lefthalf = alist[:mid]
          righthalf = alist[mid:]
  
          mergeSort(lefthalf)
          mergeSort(righthalf)
  
          i=0
          j=0
          k=0
          while i&lt;len(lefthalf) and j&lt;len(righthalf):
              if lefthalf[i]&lt;righthalf[j]:
                  alist[k]=lefthalf[i]
                  i=i+1
              else:
                  alist[k]=righthalf[j]
                  j=j+1
              k=k+1
  
          while i&lt;len(lefthalf):
              alist[k]=lefthalf[i]
              i=i+1
              k=k+1
  
          while j&lt;len(righthalf):
              alist[k]=righthalf[j]
              j=j+1
              k=k+1
  
  
  print("select the file: ")
  file_name =  tkFileDialog.askopenfile(mode='r', title='Select word list file')
  inv_data = np.loadtxt(file_name,dtype='float', comments='#', delimiter=None, converters=None, skiprows=0, usecols=None,
                  unpack=False, ndmin=0)
  mergeSort(inv_data)
  print("sorted list :", inv_data)
  </code></pre>
  
  <p>The data set is here in the below link  <a href="http://spark-public.s3.amazonaws.com/algo1/programming_prob/IntegerArray.txt" rel="nofollow">http://spark-public.s3.amazonaws.com/algo1/programming_prob/IntegerArray.txt</a></p>