title: Sorting an arraylist with integers
body: <p>I have a collection of strings in an array like this:</p>
  
  <pre><code>ArrayList&lt;String&gt; collection = new ArrayList&lt;&gt;();
  </code></pre>
  
  <p>That stores:</p>
  
  <pre><code>collection: ["(,0,D=1", "(,1,D=2", "),2,D=2", "),3,D=1", "(,4,D=1", "(,5,D=2", "),6,D=2", "),7,D=1"]
  </code></pre>
  
  <p>I have a lot of d=1 and d=2, as you can see. How do I organize this from 1 first to 2? I tried to use a for loop but the list can contain an infinite number of d=x's. Can you help me organize?</p>
  
  <p>Also, please help me so I don't change the ORDER of any numbers. Example:</p>
  
  <pre><code>collection: ["(,0,D=1", "),3,D=1", "(,4,D=1", "),7,D=1", "(,1,D=2", "),2,D=2", "(,5,D=2", "),6,D=2"]
  </code></pre>
  
  <p>So like, every parentheses will be aligned.</p>
  
  <p>I should note that collection[0] = "(,0,D=1"</p>