I think there are plenty of ways to tell person A that they should learn from person B without pitting them against one another.
Normally I talk about this in terms of rubrics for roles and levels. E.g., it's not about Amy versus Betty; it's about how Amy can get from SWE 1 to SWE 2. In the course of that discussion I am totally willing to say, "Pay more attention to the code Betty submits for a code review. She's a solid SWE 2 and you could learn from the way she does X, Y, and Z."
In other words, never say "John's code is cleaner than yours", say "I suggest you work on polishing these pull requests".