Sorting string Array Values
I am having a problem on how I couldn't sort my array values. My codes don't work the way I wanted them to:
int n;
JTextArea outputArea= new JTextArea();
String class1[]= new String [8];
JOptionPane.showMessageDialog(null,"Enter 8 Students for Class 1 ");
n=1;
for (int i=0; i<class1.length; i++){
String input=
JOptionPane.showInputDialog("Student # : "+n);
class1[i]=input;
n++;
}
String output= "\n\t Class1 Students\n";
for(int i=0; i<class1.length; i++)
output+="\t "+class1[i]+"\t"+"\t\n";
outputArea.setText(output);
JOptionPane.showMessageDialog(null, outputArea, "Initializing an Array of int Values", JOptionPane.PLAIN_MESSAGE);
for (int indx=0; indx<class1.length; indx--){
int high=1;
for(int i=2; i<= indx; i++){
if (class1[i]>class1[high]){
high=2;
}
if (high!=indx){
int temp= class1[high];
class1[high]=class1[indx];
class1[indx]=temp;
}
}