Change the index of the element which was at position 0. Swap the element basically .
let element = arr . get ( best_index ) ; h . set ( element , initial_index ) ; let temp = arr [ best_index ] ; arr . set ( best_index , arr [ initial_index ] ) ; arr . set ( initial_index , temp ) ;