title: java 8 parallelStream() with sorted()
body: <p>JDK 8 EA is out now, and I am just trying to get used to the lambda and the new Stream API. I've tried to sort a list with parallel stream, but the result is always wrong:</p>
  
  <pre><code>import java.util.ArrayList;
  import java.util.List;
  
  public class Test
  {
      public static void main(String[] args)
      {
          List&lt;String&gt; list = new ArrayList&lt;&gt;();
          list.add("C");
          list.add("H");
          list.add("A");
          list.add("A");
          list.add("B");
          list.add("F");
          list.add("");
  
          list.parallelStream() // in parallel, not just concurrently!
              .filter(s -&gt; !s.isEmpty()) // remove empty strings
              .distinct() // remove duplicates
              .sorted() // sort them
              .forEach(s -&gt; System.out.println(s)); // print each item
      }
  }
  </code></pre>
  
  <p><strong>OUTPUT:</strong></p>
  
  <pre><code>C
  F
  B
  H
  A
  </code></pre>
  
  <p>Note that each time the output is different. My questions is, is it a bug? or is it not possible to sort a list in parallel? if so, then why the JavaDoc doesn't state that? Last question, is there another operation whose output would differ depending on the stream type?</p>