title: How should I check whether a Stream<T> is sorted?
body: <p>With an <code>Iterable&lt;T&gt;</code>, it's easy:</p>
  
  <pre><code>T last = null;
  for (T t : iterable) {
      if (last != null &amp;&amp; last.compareTo(t) &gt; 0) {
          return false;
      }
      last = t;
  }
  return true;
  </code></pre>
  
  <p>But I can't think of a clean way to do the same thing for a <code>Stream&lt;T&gt;</code> that avoids consuming all the elements when it doesn't have to.</p>