It depends 😉
If you are able to get it All-In HU, then both are statistically about the same, but the problem is that very assumption...we don't always get it in HU, we don't always get it all-in and we seldom know their exact holding. If short-stacked, then I guess I'd take 22 since it is already a pair, but if deeper stacked or playing in a multi-way pot, I'd be more inclined to go all-in with AK. The reason is because AK is a premium drawing hand, so if I'm behind, then at least I have outs to improve to the (likely) best hand. However, with 22, you have less outs to improve - only another 2 is likely to help and there are only 4 in the deck (and you have 2 of them already!).
If you KNOW you can get it all-in HU, then probably 22 being a pair is slightly preferred, but without the certainly of being able to get it all-in, AK plays better post-flop.