title: Sort a list of strings in java in alphabetical order
body: <p>I have a list with some strings in this format:</p>
  <pre><code>List&lt;String&gt; ids = new ArrayList&lt;&gt;();
  
  ids.add(&quot;B-7&quot;);
  ids.add(&quot;B-5&quot;);
  ids.add(&quot;A-3&quot;);
  ids.add(&quot;B-8&quot;);
  ids.add(&quot;B-1&quot;);
  ids.add(&quot;B-6&quot;);
  ids.add(&quot;B-2&quot;);
  ids.add(&quot;B-3&quot;);
  ids.add(&quot;B-10&quot;);
  ids.add(&quot;A-1&quot;);
  ids.add(&quot;B-4&quot;);
  ids.add(&quot;B-9&quot;);
  ids.add(&quot;A-2&quot;);
  </code></pre>
  <p>I need to sort it to have this output, (iterating over the list):</p>
  <pre><code>A-1
  A-2
  A-3
  B-1
  B-2
  B-3
  B-4
  B-5
  B-6
  B-7
  B-8
  B-9
  B-10
  </code></pre>
  <p>I am using:</p>
  <pre><code>List&lt;String&gt; sortedIds = ids.stream().sorted().collect(Collectors.toList());
  </code></pre>
  <p>But instead, my output:</p>
  <pre><code>A-1
  A-2
  A-3
  B-1
  B-10   -- Error
  B-2
  B-3
  B-4
  B-5
  B-6
  B-7
  B-8
  B-9
  </code></pre>