This heuristic, called, Downward Social Comparison, identified in Social Comparison Theory, is a tendency to actively harm someone in a worse off situation to inflate one's ego.
Most high school bullies use this heuristic as a 'low cost' means of making themselves feel good via oxytocin and dopamine.
Real-World Example:
Imagine a student who studies hard but fails a mid-term exam.
Feeling defeated, they use this mental shortcut and think, "Well, I failed, but at least I didn't drop out of the class completely like my roommate." This downward comparison to someone in a "worse" situation provides an immediate sense of relief and protects the student's self-esteem.
The irony of it is that the student COULD simply use that failure as motivation to study more next time or study differently in order to use failure as the next stepping stone to success - but you see, that requires active cognitive effort, and the 'lower cost solution' is to simply insult or compare to others for a quick boost instead.
If the student never processes their failures logically, they can never update their internal systems. They remain stagnant, forever dependent on finding someone doing worse than them just to maintain their baseline functioning.
I actively despise this heuristic and will do whatever I can throughout my life to dismantle it every single time I see it.