First let's consider how the words are to be sorted:
Consequences < There < be < jim < will
so we can give them numbers so it's easier to work with:
1 = Consequences
2 = There
3 = be
4 = jim
5 = will
First we add There == 2
:
2
then will == 5
and be == 3
:
2
/ \
5 3
so far so good. But now when adding Consequences == 1
we have to heapify:
2 1
/ \ / \
5 3 ==> 2 3
/ /
1 5
And finally we add jim == 4
:
1
/ \
2 3
/ \
5 4
As to comparing letters, it's because ASCII coding. So the letters go as follows:
A < B < C < .. < Z < a < b < c < ... < z