title: Sorting Arrays - Java in eclipse
body: <p>Here is the Question:</p>
  
  <p>The international Olympics Committee has asked you to write a program to process the data and determine the medal winners for the pairs figure skating. You will be given the following file:
  Pairs.txt</p>
  
  <p>Which contains the data for each pair of skaters. The data consists of each skater’s name, their country and the score from each of eight judges on the technical aspects and on the performance aspects. A typical record would be as follows:</p>
  
  <p>Smith
  Jones
  Australia
  5.0 4.9 5.1 5.2 5.0 5.1 5.2 4.8
  4.3 4.7 4.8 4.9 4.6 4.8 4.9 4.5</p>
  
  <p>The final score for each skater is the sum of the average of the two categories of score. </p>
  
  <p>Design a class to hold the above data and the final score. Read the data in from the file and calculate the final score for each pair. Sort the array of objects , and display the results on the screen in order, giving special prominence to the medal winners.</p>
  
  <p><strong>This is my class</strong></p>
  
  <pre><code>public class Skaters {
  
      private String name1;
      private String name2;
      private String country;
      private double[] arrTech = new double[8];
      private double[] arrArt = new double[8];
      private double score;
  
      public Skaters(String n1, String n2, String c1, double[] arrT, double[] arrA)
  
      {
          this.name1 = n1;
          this.name2 = n2;
          this.country = c1;
          this.arrTech = arrT;
          this.arrArt = arrA;
  
      }
  
      public void setName1(String n1)
  
      {
          name1 = n1;
      }
  
      public void setName2(String n2)
  
      {
          name2 = n2;
      }
  
      public void setCountry(String c1)
  
      {
          country = c1;
      }
  
      public void setArrTech(double[] arrT)
  
      {
          arrTech = arrT;
      }
  
      public void setArrArt(double[] arrA)
  
      {
          arrArt = arrA;
      }
  
      public String getName1()
  
      {
          return name1;
      }
  
      public String getName2()
  
      {
          return name2;
      }
  
      public String getCountry()
  
      {
          return country;
      }
  
      public double[] getArrTech() {
          return arrTech;
      }
  
      public double[] getArrArt() {
          return arrArt;
      }
  
      public double getScore()
  
      {
          double sum = 0, avg1, avg2;
  
          for (int r = 0; r &lt; arrTech.length; r++)
  
              sum += arrTech[r];
  
          avg1 = sum / arrTech.length;
  
          sum = 0;
  
          for (int s = 0; s &lt; arrArt.length; s++)
  
              sum += arrArt[s];
  
          avg2 = sum / arrArt.length;
  
          return (avg1 + avg2);
      }
  
  }
  </code></pre>
  
  <p><strong>And this is my main</strong></p>
  
  <pre><code>import java.io.*;
  import java.util.Scanner;
  
  public class testSkaters {
  
      private static final int NUMBER_OF_JUDGES = 8;
  
      public static void main(String[] args) throws IOException {
  
          Skaters[] arrSkaters = new Skaters[50];
  
          File myFile = new File("Pairs.txt");
  
          Scanner input = new Scanner(myFile);
  
          int countSkaters = 0;
          String name1;
          String name2;
          String country;
          double[] arr1 = null;
          double[] arr2 = null;
  
          while (input.hasNext())
  
          {
  
              name1 = input.nextLine();
              name2 = input.nextLine();
              country = input.nextLine();
  
              arr1 = new double[8];
              for (int i = 0; i &lt; NUMBER_OF_JUDGES; i++)
  
                  arr1[i] = input.nextDouble();
  
              arr2 = new double[8];
              for (int j = 0; j &lt; NUMBER_OF_JUDGES; j++)
  
                  arr2[j] = input.nextDouble();
  
              Skaters s1 = new Skaters(name1, name2, country, arr1, arr2);
  
              arrSkaters[countSkaters] = s1;
  
              countSkaters++;
  
              input.nextLine();
  
          }
  
          sortSkaters(arrSkaters, 10);
  
          for (int t = 0; t &lt; countSkaters; t++)
  
          {
              System.out.println("Name 1: " + arrSkaters[t].getName1());
  
              System.out.println("Name 2: " + arrSkaters[t].getName2());
  
              System.out.println("Country: " + arrSkaters[t].getCountry());
  
              printArray(arrSkaters[t].getArrTech());
  
              printArray1(arrSkaters[t].getArrArt());
  
              System.out.println("Score: " + arrSkaters[t].getScore() + "\n");
  
          }
  
      }
  
      public static void printArray(double[] arr3) {
          for (int r = 0; r &lt; arr3.length; r++)
  
              System.out.print(arr3[r] + " ");
          System.out.println();
  
      }
  
      public static void printArray1(double[] arr4) {
          for (int s = 0; s &lt; arr4.length; s++)
  
              System.out.print(arr4[s] + " ");
          System.out.println();
      }
  
      private static void sortSkaters(Skaters[] arr, double count) {
  
          for (int i = 0; i &lt; count; i++) {
              int high = i;
  
              for (int k = i + 1; k &lt; count; k++) {
                  if (arr[k].getScore() &gt; arr[high].getScore())
  
                      high = k;
  
                  if (i != high) {
                      Skaters temp = arr[i];
                      arr[i] = arr[high];
                      arr[high] = temp;
                  }
  
              }
  
          }
      }
  }
  </code></pre>
  
  <p><strong>Here is the text file</strong></p>
  
  <pre><code>smith
  jones
  australia
  4.2 5.1 3.8 2.9 5.0 4.6 4.9 4.3
  4.9 4.8 5.8 3.8 4.9 4.6 5.0 4.5
  lennon
  murray
  england
  2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8
  3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8
  gusto
  petitot
  italia
  4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8
  5.1 5.2 5.3 5.4 5.5 5.6 5.7 5.8
  lahaie
  petit
  france
  1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8
  5.1 5.2 5.3 5.4 5.5 5.6 5.7 5.8
  bilodeau
  bernard
  canada
  2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8
  4.1 4.2 4.3 4.8 4.9 4.6 4.0 4.5
  lahore 
  pedro
  mexico
  3.2 3.1 3.8 3.9 3.0 3.6 3.9 3.3
  5.9 5.8 5.8 5.8 5.9 5.6 5.0 5.5
  maliak
  kolikov
  russia
  4.2 4.1 4.8 4.9 4.0 4.6 4.9 4.3
  1.9 1.8 1.8 1.8 1.9 1.6 1.0 1.5
  ching
  chong
  china
  5.2 5.1 5.8 5.9 5.0 5.6 5.9 5.3
  2.9 2.8 2.8 2.8 2.9 2.6 2.0 2.5
  gates
  brown
  U.S
  1.2 1.1 1.8 1.9 1.0 1.6 1.9 1.3
  3.9 3.8 3.8 3.8 3.9 3.6 3.0 3.5
  joe
  charlie
  switzerland
  2.2 2.1 2.8 2.9 2.0 2.6 2.9 2.3
  4.9 4.8 4.8 4.8 4.9 4.6 4.0 4.5
  </code></pre>
  
  <p>I did my sorting but my output is wrong. The highest score should be number one(which is the winner and so on). My code is not doing that, can anyone help me please</p>