words is an array, but you put it inside another array when you call sort
just pass words
same for sorted

cheers