@@ -0,0 +1,907 @@
+#!/usr/bin/python%0A# -*- coding: UTF-8 -*-%0A%0Afrom binary_heap import BinaryHeap%0A%0A%0Aclass BinaryHeapSort(BinaryHeap):%0A    def __init__(self):%0A        super(BinaryHeapSort, self).__init__()%0A%0A    def sort(self, nums):%0A        %22%22%22%0A        %E6%8E%92%E5%BA%8F%0A        1. %E5%A0%86%E5%8C%96%EF%BC%8C%E5%A4%A7%E9%A1%B6%E5%A0%86%0A        2. %E6%8E%92%E5%BA%8F%EF%BC%8C%E4%BB%8E%E5%90%8E%E5%BE%80%E5%89%8D%E9%81%8D%E5%8E%86%EF%BC%8C%E9%A6%96%E5%B0%BE%E5%85%83%E7%B4%A0%E4%BA%92%E6%8D%A2%EF%BC%8C%E5%AD%90%E6%95%B0%E7%BB%84%E5%A0%86%E5%8C%96%0A        :param nums:%0A        :return:%0A        %22%22%22%0A        assert type(nums) is list%0A        length = len(nums)%0A%0A        if length %3C= 1:%0A            return%0A%0A        map(self._type_assert, nums)%0A%0A        # heapify%0A        self._heapify(nums, length-1)%0A%0A        # sort%0A        for i in range(length-1, 0, -1):%0A            nums%5B0%5D, nums%5Bi%5D = nums%5Bi%5D, nums%5B0%5D%0A            self._heap_down(nums, 0, i-1)%0A%0A        return%0A%0A%0Aif __name__ == '__main__':%0A    bhs = BinaryHeapSort()%0A    nums = %5B3, 5, 2, 6, 1, 7, 6%5D%0A%0A    print('--- before sort ---')%0A    print(nums)%0A%0A    bhs.sort(nums)%0A    print('--- after sort ---')%0A    print(nums)%0A

Create binary_heap_sort.py