title: Heapsort in Python does not sorting
body: <p>I am new to python and I am trying to implement heapsort from my <a href="https://github.com/thakurabhi/Algo-Data-Structure/blob/master/Heapsort/C%2B%2B/heapsort.cpp" rel="nofollow noreferrer">C++ implementation</a>. This code is unable to sort input.</p>
  
  <p>I have written another program to test function <code>build_max_heap</code> and this function is unable to build max heap.</p>
  
  <pre><code>def max_heapify(thelist, lst_size, idx):
      largest = idx
      left_child = (2 * idx) + 1
      right_child = (2 * idx) + 2
  
      if left_child &lt; lst_size and thelist[left_child] &gt; thelist[largest]:
          largest = left_child
  
      elif right_child &lt; len(thelist) and thelist[right_child] &gt; thelist[largest]:
          largest = right_child
  
      if largest != idx:
          thelist[idx], thelist[largest] = thelist[largest], thelist[idx]
          max_heapify(thelist, lst_size, largest)
  
  def build_max_heap(thelist, lst_size):
      for curr_idx in range(lst_size // 2 - 1, -1, -1):
          max_heapify(thelist, lst_size, curr_idx)
  
  def heap_sort(thelist):
      if len(thelist) == 0:
          print("Empty list!!")
  
      elif len(thelist) == 1:
          print("Only one element!!")
  
      else:
          build_max_heap(thelist, len(thelist))
  
          for curr_idx in range(len(thelist) -1, 0, -1):
              thelist[curr_idx], thelist[0] = thelist[0], thelist[curr_idx]
              max_heapify(thelist, curr_idx, 0)
  </code></pre>