title: JTable keeps sorting numbers as Strings
body: <p>I want to sort the table correctly comparing the correct classes, not strings.
  I'm using a TableRowSorter:</p>
  <pre><code>TableRowSorter sorter = new TableRowSorter&lt;CustomModelTable&gt;(modelData);
  tablaEJ.setRowSorter(sorter);
  </code></pre>
  <p>I overrided the method getColumnClass in CustomModelTable so I get the correct class depending on the column's name (this was made because types are defined programatically):</p>
  <pre><code>@Override
      public Class getColumnClass(int columnIndex)
      {
          try {
              if (columnIndex &lt; this.getColumnCount()) {
                  String name = getColumnName(columnIndex); //This just gets the header of the column
                  name = name.toLowerCase();
                  switch (name) {
                      case &quot;int&quot;:
                      case &quot;int[]&quot;:
                      case &quot;núm.&quot;:
                      case &quot;int[][]&quot;: return Integer.class; //Or Class.forName(&quot;java.lang.Integer&quot;);
                      case &quot;byte&quot;:
                      case &quot;byte[]&quot;:
                      case &quot;byte[][]&quot;: return Class.forName(&quot;java.lang.Byte&quot;);
                      case &quot;long&quot;:
                      case &quot;long[]&quot;:
                      case &quot;long[][]&quot;: return Class.forName(&quot;java.lang.Long&quot;);
                      case &quot;float&quot;:
                      case &quot;float[]&quot;:
                      case &quot;float[][]&quot;: return Class.forName(&quot;java.lang.Float&quot;);
                      case &quot;double&quot;:
                      case &quot;double[]&quot;:
                      case &quot;double[][]&quot;: return Class.forName(&quot;java.lang.Double&quot;);
                      case &quot;boolean&quot;:
                      case &quot;boolean[]&quot;:
                      case &quot;boolean[][]&quot;: return Class.forName(&quot;java.lang.Boolean&quot;);
                      case &quot;char&quot;:
                      case &quot;char[]&quot;:
                      case &quot;char[][]&quot;: return Class.forName(&quot;java.lang.Character&quot;);
                      case &quot;string&quot;:
                      case &quot;string[]&quot;:
                      case &quot;string[][]&quot;: return Class.forName(&quot;java.lang.String&quot;);
                      default: return Class.forName(&quot;java.lang.String&quot;);
                  }
              }
          } catch (Exception e){
  
          }
          return null;
      }
  </code></pre>
  <p>Here's an screenshot:
  <a href="https://i.stack.imgur.com/lcnFk.png" rel="nofollow noreferrer">Table wrongly sorted</a></p>
  <p>The most curious thing is that I print the types:</p>
  <pre><code>for (int i = 0; i &lt; tablaEJ.getModel().getColumnCount(); i++) {
       System.out.println(tablaEJ.getModel().getColumnClass(i));
  }
  </code></pre>
  <p>And it returns the expected output (print of the above table):</p>
  <pre><code>class java.lang.Integer
  class java.lang.Integer
  class java.lang.Integer
  class java.lang.Integer
  </code></pre>
  <p>Honestly, I don't know what I'm doing wrong.</p>