implement heap sort in Erlang