File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed
Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change 1313def sort (_list ):
1414 """
1515 heap sort algorithm
16+ Create the heap using heapify().
17+ This is an implementation of max-heap, so after bullding the heap, the max element is at the top (_list[0]).
18+ We move it to the end of the list (_list[end]), which will later become the sorted list.
19+ After moving this element to the end, we take the element in the end to the top and shift it down to its right location in the heap.
20+ We proceed to do the same for all elements in the heap, such that in the end we're left with the sorted list.
1621
1722 :param _list: list of values to sort
1823 :return: sorted values
1924 """
20- # TODO: Add description of how this works!
2125
2226 # create the heap
2327 heapify (_list )
You can’t perform that action at this time.
0 commit comments