title: QuickSort by reading a numerical txt file using Python
body: <p>I have updated my program, it did not give me an error. However it gave me the same txt file without sorting</p>
  <p>txt_array.txt
  54044
  14108
  79294
  29649
  25260
  60660
  2995
  53777
  49689
  9083</p>
  <pre><code>#QuickSort with first element to be a pivot element
  
  def choosePivot(arr, l, r): 
          i = (l - 1) #first index
          pivot = arr[l] #first element to be a pivot
      
          for j in range(l+1, r+1):
                  if arr[j] &lt; pivot:
                      arr[i], arr[j] = arr[j], arr[i] #swapping
                      i=i+1 #increment i
          position = i-1 #checking position
          arr[l], arr[r] = arr[position], arr[l]
          return position
  
  def quickSort(arr, l, r):
      if len(arr) == 1:
          return arr
      if l &lt; r:
          p = choosePivot(arr, l, r)
          quickSort(arr, l, p-1)
          quickSort(arr, p+1, r)
  
  def readFile(filename, l):
      # f = open(filename, &quot;r&quot;)
      with open(filename, &quot;r&quot;) as f:
          for line in f:
              l.append(int(line))
  
      if f.closed == False:
          f.close()
  
  def main ():
      txt_array = []
      size = len(txt_array)
      readFile(&quot;array.txt&quot;, txt_array)
      print (txt_array[:]) #Appear all numbers of the array
      print (&quot;Numbers of given: &quot; + str(len(txt_array)))
      quickSort(txt_array, 0,size-1)
      print(&quot;Sorted array: &quot; + str(txt_array))
      return 0 
  main()
  </code></pre>
  <p>my outpout is</p>
  <p>[54044, 14108, 79294, 29649, 25260, 60660, 2995, 53777, 49689, 9083]</p>
  <p>Numbers of given: 10</p>
  <p>Sorted array: [54044, 14108, 79294, 29649, 25260, 60660, 2995, 53777, 49689, 9083]</p>