title: Sorting an Array with Doubles Java
body: <p>I'm reading a text file into a 2D array. The first column ( the one I'm sorting on) is almost all Doubles. As you all probably know, it sorts 1.1  1.6  25.6  6.4, how can I fix this?</p>
  
  <pre><code>import java.io.*;
  import java.util.*;
  
  public class Sort {
  
      public static void main(final String[] args) throws FileNotFoundException {
          FileOutputStream out = new FileOutputStream("/Users/evanlivingston/2d.txt");
          PrintStream pout = new PrintStream(out);
          List&lt;String[]&gt; entries = new ArrayList&lt;String[]&gt;();
          Scanner sc = new Scanner(new File("/Users/evanlivingston/dists/0.txt"));
          while (sc.hasNext()) {
              entries.add(new String[] { sc.next(), sc.next()});
          }
          String[][] table = entries.toArray(new String[0][]);
  
          Arrays.sort(table, new Comparator&lt;String[]&gt;() {
              @Override
              public int compare(String[] s1, String[] s2) {
                  String t1 = s1[0];
                  String t2 = s2[0];
                  return t1.compareTo(t2);               
              }      
          });
          pout.print(java.util.Arrays.deepToString(table));
          pout.close();
      }
  }
  </code></pre>
  
  <p><strong>EDIT</strong>:<br>
  Here is my updated code. It won't compile.</p>
  
  <pre><code>import java.io.*;
  import java.util.*;
  
  public class Sort {
      public static void main(String[] args) throws FileNotFoundException {
          FileOutputStream out = new FileOutputStream("/Users/evanlivingston/2d.txt");
          PrintStream pout = new PrintStream(out);
          List&lt;Coords&gt; coords = new ArrayList&lt;Coords&gt;();
          {
              Scanner sc = new Scanner(new File("/Users/evanlivingston/dists/0.txt"));
              while(sc.hasNextLine()) {
                  String[] numstrs = sc.nextLine().split("\\s+");
              }
              String[][] table = coords.toArray(new String[0][]);
  
              Arrays.sort(table, new Comparator&lt;Double[]&gt;() {
                  @Override
                  public int compare(Double[] s1, Double[] s2) {
                      double a = Double.parseDouble(s1);
                      double b = Double.parseDouble(s2);
                      compare(a, b);
                  }
              });
              pout.print(java.util.Arrays.deepToString(table));
              pout.close();
          }
      }
  }
  </code></pre>