title: JTable fails to sort Integers and Double values properly
body: <p>I have read several questions about JTable sorting:</p>
  
  <p><a href="https://stackoverflow.com/questions/9090974/problems-with-jtable-sorting-of-integer-values">Problems with JTable sorting of integer values</a></p>
  
  <p><a href="https://stackoverflow.com/questions/4553448/jtable-sorting-specific-field/4553842#4553842">JTable + Sorting specific field</a></p>
  
  <p>but I still can't manage to get it right, for some reason.</p>
  
  <p>I have written this:</p>
  
  <pre><code>String allItemsColumns [] = { "#", "Name", "Stock", 
      "Price", "Type", "Supplier", "Location", "" };
  allItemsTableModel = new DefaultTableModel(null, allItemsColumns);
  allItemsTable = new JTable(allItemsTableModel)
  {       
      Class&lt;?&gt;[] types = { Integer.class, String.class, Integer.class, 
           Double.class, String.class, String.class, String.class, ImageIcon.class };
  
      @Override
      public Class&lt;?&gt; getColumnClass(int columnIndex) {
          return this.types[columnIndex];
      }
  };
  </code></pre>
  
  <p>but I still get </p>
  
  <pre><code>0
  10000
  20
  </code></pre>
  
  <p>when I sort stock. Probably it's an obvious one, but I'm really missing it at the moment.</p>
  
  <p>I do not think it matters how I add info as I (think so that) tell it to read the columns as Integers, Doubles or Strings</p>
  
  <p>My sorting method:</p>
  
  <pre><code>allItemsTable.setAutoCreateRowSorter(true);
  TableRowSorter&lt;DefaultTableModel&gt; rowSorter = 
       (TableRowSorter&lt;DefaultTableModel&gt;)allItemsTable.getRowSorter();
  rowSorter.setComparator(3, new Comparator&lt;String&gt;() {
  
      @Override
      public int compare(String o1, String o2)
      {
          return Integer.parseInt(o1) - Integer.parseInt(o2);
      }
  
  });
  </code></pre>
  
  <p>I have taken it from one of the questions I saw. Column #3 is "Stock" which is Integers only, but the result, like I said is:</p>
  
  <pre><code>0
  10000
  20
  </code></pre>