When you import data, it is strongly recommended to use two following functions to "clean" the blank characters in your cells.
The TRIM function
This function is very useful for cleaning all the spaces before and after a string.
The function is very simply to use. There is only one argument, your text to clean.
Example when to use the TRIM function
But the sort doesn't respect the alphabetic order because the words DDDD and FFFF begin with a blank.
So we must clean strings with the TRIM function to remove the blank spaces.
To keep the result "clean", convert the formulas in value by making a paste special VALUE >like in this video.