fix some bugs and add heapsort