heap sort implemented, stupid indices