title: Java- How to sort an array of strings that contain periods / dots without extending comparator?
body: <p>Java noob here. I want to sort an array of strings that contain periods / dots from smallest to largest.</p>
  
  <p>So an array containing:</p>
  
  <pre><code>1.0.3
  1.0.12
  1.0.2
  </code></pre>
  
  <p>Is incorrectly being sorted like this:</p>
  
  <pre><code>1.0.12
  1.0.2
  1.0.3
  </code></pre>
  
  <p>When sorted <strong>correctly</strong> should be:</p>
  
  <pre><code>1.0.2
  1.0.3
  1.0.12
  </code></pre>
  
  <p>Here is the code I have so far, but it sorts it incorrectly.</p>
  
  <pre><code>public static String[] sort(String[] l) {
          String[] ll=new String[l.length];
          for(int i=0;i&lt;l.length;i++)
          {
  
          }
  
          for (int i = 0; i &lt; l.length - 1; ++i) {
              int minIndex = i;
              for (int j = i + 1; j &lt; l.length; ++j) {
  
                  if (l[j].compareTo(l[minIndex]) &lt; 0) {
                      minIndex = j;
                  }
              }
  
              String temp = l[i];
              l[i] = l[minIndex];
              l[minIndex] = temp;
  
  
          }
          return l;
  
  
      }
  </code></pre>