By default, sort_values puts the smallest y first. But in the doc (containing F), y=0 is at the bottom of the shape and y grows as you go up. So you ended up printing the bottom stroke of your “F” first, then the middle and then the top giving you an upside-down “F.”
To fix this you would need to define the sorting order of y-cordinates as descending in your getTableDataSorted function:
tableData[0].sort_values(by=["y-coordinate","x-coordinate"], ignore_index=True,ascending=[False, True])
As the doc with the lengthier message is already laid out with the highest y-values first, asking pandas to sort y descending doesn’t change its row order. In contrast, the “F” doc had y ascending (bottom→top), so flipping to descending is what corrects its orientation.