well it would be good if we can see the calculation or maybe understeand the logic.
but from what i see IV is prio, 100% IV is excelent, second thing is LV and then CP.
from mine research , i had 2 Flareons on same IV with same stats , only difference was lv , fist was lv 8 and other lv 10, i upgraded booth to lv 11 and here the results:
Name IV LV atk def stam CP HP
Flareon 95.56% 11 15 15 13 825 63
Flareon 95.56% 11 15 15 13 787 61
825 CP was catched as lv 10 and 787 as lv 8.
with higher level you have more cp that is corret but a lower pokemon can't get to a higher level catched pokemon cp sometimes.
if this site is right
https://rankedboost.com/pokemon-go/tier-list/
the calculation will need be something like this :
check IV , if same then i would compare level and if there is a diference like on mine i would add to the CP value to the lower one the CP that the pokemon gets per level (so we have now IV equals, LV equals ) and then determine the CP condition...
this is only if the site is right with CP per level for each pokey.