While the Flash has shown the proper measures in speed, especially when we have calculations on Superman’s speed which has been confirmed to at the very least reverse time. Sonic has always been showing to consistently adapt to such environments, as he was able to restore timelines and distorted dimensions from his speed alone. The final comparison is whether the flash can outrun sonic faster before he can adapt and outrun the flash overall. So in quick short bursts I’d say the flash would have wins in those regards, but in longer durations of a race that causes adaptations, Sonic takes the win by long shots.