I need your help again. how do I sort the records in the txt file in Java?
Here's the code how i save the scores
try {
    File highscore = new File("highscore.txt");
    PrintWriter output = new PrintWriter(new FileWriter(highscore, true));
    if (highscore.exists()) {
        System.out.println();
        System.out.println("High Score:");
    }
    output.println(name + " - " + totalScore);
    output.close();
} catch (IOException e) {
    System.out.println(e);
}
and here's the code how I display the scores
try {
    FileReader fr = new FileReader("highscore.txt");
    BufferedReader br = new BufferedReader(fr);
    String s;
    while ((s = br.readLine()) != null) {
        System.out.println(s);
    }
    br.close();
} catch (IOException e) {
    System.out.println(e);
}
My current output is:
Player1 100
Player2 200
Player3 50
And i want to sort the score from highest to lowest, how do I go about that? thank you in advance!
the output that I want to get is:
Player2 200
Player1 100
Player3 50