title: How to sort object using java 8 streams
body: <p>I am using the stream API in java 8 to handle my collections. However, I am wondering what would be an elegant way to sort my objects in a given order, using this API.</p>
  
  <pre><code>SortedCollection = inputCollection.stream()
      .map(e -&gt; {
          return new Element(e.id, e.color);
      }).collect(Collectors.toList());
  </code></pre>
  
  <p>Here I would like to sort the elements that have been mapped, using the id
  attribute.</p>
  
  <p>Any idea ? Thanks !</p>