import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Arrays;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
public class High {
High() throws IOException{
FileReader read = new FileReader("user.txt");
BufferedReader file = new BufferedReader(read);
String readFile = file.readLine();
String real = "";
while (readFile!=null) {
real = real+readFile;
readFile = file.readLine();
}
String hightscore[] = real.split(",");
String name[] = new String[hightscore.length];
String score[] = new String[hightscore.length];
int scoreCheck[] = new int[hightscore.length];
int scoreCheck2[] = new int[hightscore.length];
int scoreCheck3[] = new int[hightscore.length];
for(int i =0;i<hightscore.length;i++){
String nameSp[] = hightscore[i].split(" ");
name[i] = nameSp[0];
score[i] = nameSp[1];
}
for(int i =0;i<scoreCheck.length;i++){
scoreCheck[i] = Integer.parseInt(score[i]);
}
scoreCheck2 = scoreCheck;
for(int i =0;i<scoreCheck2.length;i++){
scoreCheck3[i] = scoreCheck2[i];
}
//JOptionPane.showMessageDialog(null,scoreCheck3[0]);
Arrays.sort(scoreCheck);
//JOptionPane.showMessageDialog(null,scoreCheck3[0]);
String showHighScore[] =new String[scoreCheck.length];
String showOnDilog ="";
for(int i=0; i<scoreCheck.length;i++){
for(int j=0;j<scoreCheck2.length;j++){
if(scoreCheck[i]==scoreCheck3[j]){
showHighScore[i] = name[j]+" "+scoreCheck3[j];
}
}
}
for(int i=showHighScore.length-1;i>=0;i--){
showOnDilog = showOnDilog+showHighScore[i]+"\n";
}
JOptionPane.showMessageDialog(null," Hight Score\n"+showOnDilog ,"High Score",JOptionPane.INFORMATION_MESSAGE );
}
}