I'm confused that you're supposed to sort the array. countarray is 26 elements, representing 26 letters of the alphabet. Each time a letter is seen the corresponding array entry is incremented.

So...