Refactored compare.js to use a makeshift 'spaceship' operator