First of all, your classmate takes this bus to Yangzhou. You buy two tickets from Yangzhou to Shanghai and wait for him.
K8453/K8456 Nantong-Yangzhou 08:48- 1 1:35 Air conditioning is 2 hours and 47 minutes faster 183 km.
You both go to Shanghai at the same time.
T7785/T7788 Yangzhou-Shanghai 12:20- 17:33 Air-conditioned express train 5 hours 13 minutes 4 16 kilometers.
I slowly sorted out this route. If you are not satisfied, contact me directly at Baidu Hi, and I will change it for you ~ ~