Q:

Sorting highscore by time and number of guesses

As of now my highscore list is only sorted by number of guesses.  I would like entries with identical number of guesses to also be sorted by time in ms, in descending order.  Tried searching and found some similar Q's but couldn't really find a solution.  Any pointers will be greatly appreciated!  Feel free to comment on other parts of my code as well! 
import java.util.*; 

public class Game {

private static ArrayList<highScore> score = new ArrayList<highScore>();

private class highScore implements Comparable<highScore> {

    int guessCount = 0;
    double playerTime = 0;
    String playerName;

    public highScore (int guessCount, double playerTime, String playerName) {
        this.guessCount = guessCount;
        this.playerTime = playerTime;
        this.playerName = playerName;
    }

    public String toString() {
        String scoreList = (this.playerName + "\t\t" + this.guessCount + "\t\t" + this.playerTime);
        return scoreList;
    }

    public int compareTo(highScore hs) {
        if (((Integer)this.guessCount).compareTo(((Integer)hs.guessCount)) > 0)
            return 1;
        else
            return -1;
    }
}

public static void main(String [] args) {

    boolean playGame = true;
    Scanner scan = new Scanner(System.in);

    Game g = new Game();

    while(playGame) {
        g.start();

        System.out.println("\nPlay again?"); 
        String s = scan.nextLine();
            if (s.equalsIgnoreCase("n")) {
                System.out.print("Quitting...");
                playGame = false;
        }
    }
}

public void start() {

    int number = (int) (Math.random() * 1001 );
    int guess = -1;
    int guessCount = 0;
    String guessStr, playerName;
    String quit = "quit";
    Scanner scan = new Scanner(System.in);
    boolean play = true;

        System.out.print("Welcome to the greatest guessing game of all time!"  + 
        "\nGuess a number between 1-1000!"  + 
        "\nType \"quit\" to quit."); 

        long startTime = System.currentTimeMillis();

        System.out.println("\nDEBUG, nr is: " + number);

        while (guess ! = number && play) {
            try {
                System.out.print("\nEnter your guess: ");
                guessStr = scan.nextLine();
                    if (guessStr.equalsIgnoreCase("quit")) {
                        play = false;
                        System.out.println("Quitting...");
                        return;
                }
                guess = Integer.parseInt(guessStr);

                if (guess <= 1 || guess > 1000) {
                    System.out.println("Invalid guess, won't count, try again!"); 
                }
                if (guess < number) {
                    System.out.println("Too low, try again!"); 
                    guessCount++;
                }
                if (guess > number) {
                    System.out.println("Too high, try again!"); 
                    guessCount++;
                }
            }
            catch(NumberFormatException e) {
                System.out.println("Sorry, only numbers.  Try again!"); 
            }
            catch (InputMismatchException ex) {             
                System.out.println("Sorry, only numbers.  Try again!"); 
            }
        }

        if (guess == number) {
            long endTime = System.currentTimeMillis();
            long gameTime = endTime - startTime;

            System.out.println("Nice, the correct number is " + number + "!"); 
            System.out.print("You nailed it after " + (int)(gameTime)/1000 + " seconds and " + guessCount + " tries!"); 
            System.out.println("\nEnter your name!"); 

            playerName = scan.nextLine();
            score.add(new highScore(guessCount, gameTime, playerName));
            Collections.sort(score);

            System.out.println("Name ------- Guesses -------- Time in ms");
            for (highScore h: score) {
                System.out.println(h);
            }
        }
     }
 }

A:

The compareTo() method of highScore has to be implemented as below
public int compareTo(highScore hs)
{
    if (((Integer)this.guessCount).compareTo(((Integer)hs.guessCount)) > 0)
        return 1;
    else
    {
        if(this.guessCount == hs.guessCount)
        {
          if(this.playerTime > hs.playerTime)
          {
             return 1;
          }
          else
          {
             return -1;
          }
        }

        return -1;
    }
}

