title: Sort of double values outputting wrong data
body: <p>Ive had some issues with a program for university. I'm down too the last part of the assignment and what i thought would be the easy bit has quickly become the hardest. I'm asked to sort values from a <code>.cvs</code> file by the distance (values like <code>17.0123874627346,0.123761947</code>, etc)</p>
  
  <p><strong>Here is my code:</strong></p>
  
  <pre><code>public void sortDistance() {
      System.out.println("before distance sort");
      for (int k = 0; k &lt; ntracks; k++) {
          System.out.println(tracks[k].getDistance());
      }
      for (int i = 0; i &lt; ntracks; i++) {
          //find the index of the minimum position
          int index = i;
          //looping through array of distances
          for (int j = i + 1; j &lt; ntracks; j++) {
              if  (tracks[index].getDistance() &lt; tracks[j].getDistance())             
              {
                  //position j is new mimum index
                  index = j;
              }
          }
          //swap the two values around so smallest becomes track index
          Track smallerTrack  = tracks[index]; 
          tracks[index] = tracks[i]; 
          tracks[i] = smallerTrack;
      }
      System.out.println(" after distnace sort");
      for (int k = 0; k &lt; ntracks; k++) {
          System.out.println(tracks[k].getDistance());
      }
  }
  </code></pre>