Python has a function that lets you replace a substring from a string in something else, you could use that to make your job easier (even better, there's a function that replaces characters only, it should be quicker). Be aware of how many times you use that though, if you use it too many times it will bring up execution time.
If you want to continue with your idea, why don't just compare the characters before applying ord? So you can verify that the character is space/tab doing char = " " or char = "\t", or just compare the ord like ord(char) = ord(" ") or ord(char) = ord("\t").
One last thing, if you need to sort the strings you have to use the "no-whitespace" strings, unless you make a function that sorts while ignoring whitespaces.