They have 20 years of technology gap in between. F-22 being better than F-35 is against the nature of technology. If F-22 is better than the F-35, the USA should keep it for itself. But, they want to retire it, meaning that the USA doesn't even want to keep it for itself.The USA has a policy to not export their most adavnaced fighter jet in order to maintain their military superiority
Till this date, the US has refused to sell its F22 raptors to even the friendliest nations like Israel while initiating F35 sales like hotcakes
During Trump rule, he wanted to sell the F22 to Israel but the congress, pentagon and even the Senate refused as far as I heared. It is qyuite rare to have all such institutions (that are normally opposing each other) to actually agree on something unlese it is due to a decent reason ofcourse
We can keep arguing about which is better, but all of us deep inside knows that the F22 is better since the US refuses to sell it to anyone
F-22 has a reputation for being the most advanced fighter, and this reputation is also its doom. They probably intentionally put F-35 behind F-22 in order to prevent it from the same doom. If they openly agree that F-35 is better than the F-22, there would be some congressmen who try to block its sales and eventually succeed, just like they did in the F-22.