Add code into heapsort so that it can return actions.