Commented compareKey method for clarity