heap sort works but I would like to git rid of check for j < n