Implement three-way comparison. Need to fix up ranks.