title: Shellsorting an array from an input file
body: <p>The full project is to take data in from a file which is a text file containing a list of all 201 countries and their respective rates of internet use in alphabetical order. Here is an example </p>
  
  <pre><code>Afghanistan                 7
  Albania                    63
  Algeria                    20
  Andorra                    97
  Angola                     23
  ...
  </code></pre>
  
  <p>With this we have to Shellsort (specifically) the data numerically. I have successfully done this but I only am outputting a list of the percentages, where as I need the countries listed as well. Here is my code: </p>
  
  <pre><code>import java.io.*;
  import java.util.*;
  
  public class InternetUsers {
  public static void main(String[] args) throws IOException{
      // TODO Auto-generated method stub
  
      String populationString = "";
      String[] line = new String[201];
      int populations[] = new int[201];   
  
      Scanner fileIN = new Scanner(new File("F:/CountrySortedAlpha.txt"));
  
      while(fileIN.hasNext()){
          for(int i = 0; i &lt; 201; i++){
              populationString = fileIN.nextLine().substring(26, 29);
              populations[i] = Integer.parseInt(populationString.trim());
          }   
          int j;
              for(int gap = populations.length / 2; gap &gt; 0; gap /= 2){
                  for (int k = 0; k &lt; populations.length; k++){   
                  }
                  for (int t = gap; t &lt; populations.length; t++){
                      int tmp = populations[t];
                          for(j = t; j &gt;= gap &amp;&amp; (tmp &lt; populations[j - gap]); j -= gap){
                              populations[j] = populations[j - gap];
                          }
                          populations[j] = tmp;
                  }
          }
          System.out.println("\nFinal sorted order: ");
          for(int k = 0; k &lt; populations.length; k++){
              System.out.print(populations[k]);
              System.out.println("");
          }
          System.out.println();
      }   
  }
  }
  </code></pre>
  
  <p>So my question is how am I to go about outputting the countries as well? do I need to completely redo the way I sorted? Here is my sample output:</p>
  
  <pre><code> Final sorted order: 
   1
   1
   2
   2
   2
   2
   2
   3
   ....
  </code></pre>