Refactorated. Splitted the recursive method sortWords into sortWords and splitWords