So, it seems you main Links/Fire emblem, I don't think you should have much of a problem with sonic once you learn about him.
I disagree with Missile, I play sonic a ton and I've noticed many many of his attacks have very low priority (but who cares because of how fast he is). What this means though is that you can challenge all of his approaches with any attack (specifically d-tilt as marth/roy, any projectile as links, and I dunno for Ike). But, if you don't feel your timing is good enough, just shield a lot. sonic's shield pressure isn't the greatest and the only thing he can do is jc grab or side b-jc grab, but those are fairly obvious approaches.
Also, a good sonic player can mix up timing a ton, with the different speeds you can launch down b with, side b, the delay from the homing attack, it's pretty hard to predict a good sonic. The main thing is, force him to approach you. What's really scary is that if marth throws out a fsmash on the right side of battlefield and sonic is on the far left, sonic can actually get all the way to you with several attacks after the hitboxes are gone for fsmash and before you can do anything. So getting baited can be very painful. But if you keep throwing projectiles as links, sonic will have to come toward you, and if you play smart as FE characters you can get sonic to be in bad position (especially with marths grab range considering you can grab sonic out of every single one of his ball attacks).