Sorting lists of words using linked lists