Fix heapsort in ruby