title: Python sorting list with negative number
body: <p>In attempt to learn python by practicing, I am trying to implement and test out quick sort algorithm using python.</p>
  
  <p>The implementation itself was not difficult, however the result of the sort is somewhat puzzling:</p>
  
  <p>When I sort a list</p>
  
  <p>['35', '-1', '-2', '-7', '-8', '-3', '-4', '20', '-6', '53']</p>
  
  <p>the result gives me</p>
  
  <p>['-1', '-2', '-3', '-4', '-6', '-7', '-8', '20', '35', '53']</p>
  
  <p>So the list is sorted however the negative integers are sorted in reverse order.</p>
  
  <p>I suspect this may be the problem with the fact that I am sorting a list of ints read in from a file, and the type of the int is actually not int but something else (string, perhaps.) What could I possibly do to fix this problem?</p>
  
  <p>here is the code for the quicksort implementation</p>
  
  <pre><code>#quicksort -&gt; the conquer part of the algorithm
  def quicksort(input_list, start_index, end_index):
      if start_index &lt; end_index:
          #partition the list of integers.
          pivot = partition(input_list, start_index, end_index)
          #recursive call on both sides of the pivot, that is excluding the pivot itself
          quicksort(input_list, start_index, pivot-1)
          quicksort(input_list, pivot+1, end_index)
      return input_list
  
  #divide part of the algorithm
  def partition(input_list, start_index, end_index):
      #declare variables required for sorting
      pivot = input_list[start_index]
      left = start_index + 1
      right = end_index
      sorted = False
  
      while not sorted:
          #break condition so that left index is crossed with right index
          #or if the value of left crosses the pivot value
          while left &lt;= right and input_list[left] &lt;= pivot:
              #increment left index
              left = left + 1
          #break the loop when right and left indexes cross
          #or if the right value crosses the pivot value
          while right &gt;= left and input_list[right] &gt;= pivot:
              right = right-1
          if right &lt; left:
              sorted = True
          else:
              #swap places for left value and the right value cause they are not in order
              temp = input_list[left]
              input_list[left] = input_list[right]
              input_list[right] = temp
      #swap the value at start index with what's now at the right half. Then return right for the new pivot
      temp = input_list[start_index]
      input_list[start_index] = input_list[right]
      input_list[right] = temp
      return right
  </code></pre>
  
  <p>Any help is appreciated. Thank you all for your time and help.</p>