Why?
I can bring up another example: Bellamy. IIRC, Bellamy had no strong teacher to learn haki and in terms of powerlevels, dude was one shot by Luffy despite the latter not using his DF to k.o. him.
At least Sanji had the opportunity to learn koka from a high tier.
Based on what if we exclude Yonko crews?
Makes sense.
So what? Did Doflamingo actually train Bellamy during the timeskip?
Apart from that, Sanji has been taught by Ivankov up to 2 years as well and unlike Bellamy, who was yet part of Doflamingo's family IIRC, Ivankov actually taught him something.
Heck, even if Ivankov didn't train him directly, there were enough opponents in which Sanji could have learned koka.
Obviously good enough in which Sanji developed good CoO.