Heap sorting. The first approach.