First off,
Sonic is low tier on every stage but flat that don't have many platforms, on mainly flat stages a good sonic will **** you up if your not careful. With that said you weren't careful.
What I usually do when I fight Sonics is explore the holes he has in his approach game and go from there while using the chain only when I think he's just about to "jump into the ****". Needless to say the chain completely ***** Sonic and if used under a non moving platform perfectly sonic has ZERO options left beside hoping you will **** up.
Whenever Sonic goes into his ball like state on the ground he has many options of approach the best way to counter this is by throwing a single needle to stop him. The reason single is bolded is because there's a good chance that if he goes into the air that the lag from throwing multiple needles will leave you open for a attack.
Now if you can't throw any needles or you are too close to throw needles but your not in grab range then just shield. Sonic's attacks are fast but will always leave him open after they finish if you predict him right/wait long enough. The only exception for this is if he start the ball like state in the air since he can cancel it into a grab, which completely ***** hiding in your shield.
Basically the best way to deal with a sonic though is just ftilting them away as he approaches you from the ball like state. I'm fairly sure the ftilt beats it no matter how long he hold it if you are far away enough. Trust me on this, if I could ftilt Sonic's away online then you should be able to do is as well especially offline.
Well I have a 13 hour shift in 4 hours so I'm gonna go end it with that. If I manage to think up anything else really worth note that everyone else hasn't already like your dash attacking then I'll edit my post later on tonight.
By the way, Sonic vs Sheik matches are always fun as hell to watch ^-^