Added sortLetters function