title: Stream with sorted() before findFirst() is no longer lazy
body: <p>I have a list of elements, I need to find the first element that satisfy the condition then exit using Java 8 streams.</p>
  
  <p>I think the following code unfortunately evaluate all available element which doesn't what i need, I need to evaluate items one by one and stop (<code>break</code>) when find the first match:</p>
  
  <p>I am here sorting the elements, then map the element to its <code>url</code> attribute then try to filter if the <code>url</code> is not null or empty then find <code>first</code> match!</p>
  
  <pre><code>Arrays.stream(dataArray)
  .sorted(Comparator.comparing(d -&gt; d.getPriority()))
  .peek(o -&gt; System.out.println("SORT: " + o))
  .map(d -&gt; d.getOriginalURL(shortUrl))
  .peek(o -&gt; System.out.println("MAP: " + o))
  .filter(u -&gt; u != null &amp;&amp; !u.isEmpty())
  .peek(o -&gt; System.out.println("FILTER: " + o))
  .findFirst().orElse("");
  </code></pre>
  
  <p>But the output shows that, all items are evaulated even if the first one matches the <code>if</code> condition (<code>filter</code>) operation.</p>
  
  <pre><code>Data[] data = new Data[] { new ParseData(), new InMemoryData() };
  System.out.println("&gt;&gt;&gt; " + getOriginalURL(data, ""));
  </code></pre>
  
  <p>OUTPUT:</p>
  
  <pre><code>SORT: mhewedy.usingspark.data.InMemoryData@7adf9f5f
  MAP: InMemory URL
  FILTER: InMemory URL
  SORT: mhewedy.usingspark.data.ParseData@85ede7b
  MAP: Parse.com URL         &lt;&lt;&lt; THIS SHOULD NOT HAPPEN
  FILTER: Parse.com URL      &lt;&lt;&lt; AND THIS TOO
  &gt;&gt;&gt; InMemory URL
  </code></pre>
  
  <p>As output shows, the stream doesn't stop when the filter matches with the first element, instead it continue evaluating the second element too!</p>
  
  <p><strong>I want to do like this:</strong></p>
  
  <pre><code>Arrays.sort(dataArray, Comparator.comparing(d -&gt; d.getPriority())); // sort
  
  for (Data data : dataArray) {
      String url = data.getOriginalURL(shortUrl);           // map
      if (url != null &amp;&amp; !url.isEmpty()) {                  // filter
          System.out.println("url :" + url);            
          return url;                                   // find first
      }
  }
  </code></pre>