It is said:
In the Sega video game Sonic Unleashed, the hedgehog’s maximum speed is measured to be approximately 2,889 mph.
and that:
Barry Allen may be known for his superspeed, but just how fast can he run? Unfortunately for fans, it’s not quite the speed of light. According to The Flash, Allen’s top speed is Mach 3.3, or 2,532 miles per hour.
and another speedster:
Superhuman Speed: Wally is capable of moving at incredible superhuman speeds. He was able to cover 7,000 miles in 6.25 seconds, and even accelerate far beyond light-speed to the point of entering the Speed Force dimension.
So while Sonic might beat Barry Allen’s Flash:
The Flash is faster than Sonic. Sonic the hedgehog runs at the speed of sound. While the Flash can run so fast he can jump through time. … The Flash because Sonic can’t break the sound barrier and bend time.