title: Sorting text from text File
body: <pre><code>    package individual;
      import java.io.*;
      import java.util.*;
      public class Individual{
  
          public static void getContent(Scanner inp,String[] contents){
              int i;
              for(i=0;i&lt;contents.length;i++)
                  contents[i]=inp.next();
  
         public static void Sort(String[] contents){
             int i,j;
             int min;
             String temp;
  
             //for selection sort
             for(i=0;i&lt;contents.length-1;i++)
             {
                 min=i;
  
                 for(j=i+1;j&lt;contents.length;j++)
                     if(contents[j].compareTo(contents[min])&lt;0)
                         min=j;
                 temp=contents[i];
                 contents[i]=contents[min];
                 contents[min]=temp;
  
             }
         }
  
          public static void main(String[] args) throws FileNotFoundException{
  
              String[] newAyat=new String[50];
              //read From file that i save in drive
              Scanner inFile=new Scanner(new FileReader("D:\\newFile.txt"));
  
              getContent(inFile,newAyat);
              Sort(newAyat);
  
      }
     }
  }
  </code></pre>
  
  <p>so when i run the program i got an error. The output is not what i want. Is there any problems with my codes. And how to print out the sorting results?</p>
  
  <p>This is the question that I try to solve:
  Based on the list relates , you must program can display a list of words beginning with ' a ' , ' b ' , ' c ' and so on .</p>