Fixing compareTo to take ordering into account.