Rank-Then-Score: Enhancing Large Language Models for Automated Essay Scoring