You can't use tsort directly if some of your input strings contain whitespace.
You can check the source, you'll see the delimiters are hardcoded to space, tab and newline and there's no option to change them.
If you want to use tsort on a data set where words may contain whitespace, my recommendation would be to pre-process the data set to encode whitespace as a non-blank character (or sequence of non-blank characters), then run tsort on it and finally post-process the final output to decode it back into the original whitespace.
You can probably use
sed for the pre- and post-processing steps. Which character to use to encode whitespace depends on your data set, if there are other characters that are invalid (e.g.
\), maybe you can simply use them directly. Otherwise, you might want to consider a two character encoding (e.g. encode space as
\s) and include a way to encode the quoting character itself (e.g.
\\ to encode a single backspace.)