title: How to use Java streams to create a list out of a map site
body: <p>Starting with a map like:</p>
  <pre><code>Map&lt;Integer, String&gt; mapList = new HashMap&lt;&gt;();
      mapList.put(2,&quot;b&quot;);
      mapList.put(4,&quot;d&quot;);
      mapList.put(3,&quot;c&quot;);
      mapList.put(5,&quot;e&quot;);
      mapList.put(1,&quot;a&quot;);
      mapList.put(6,&quot;f&quot;);
  </code></pre>
  <p>I can sort the map using Streams like:</p>
  <pre><code>    mapList.entrySet()
      .stream()
      .sorted(Map.Entry.&lt;Integer, String&gt;comparingByKey())
      .forEach(System.out::println);
  </code></pre>
  <p>But I need to get list (and a String) of the correspondent sorted elements (that would be: a b c d e f) that do correspond with the keys: 1 2 3 4 5 6.</p>
  <p>I cannot find the way to do it in that Stream command.</p>
  <p>Thanks</p>
  <p>As @MA says in his comment I need a mapping and that is not explained in this question: <a href="https://stackoverflow.com/questions/1026723/how-to-convert-a-map-to-list-in-java">How to convert a Map to List in Java?</a></p>
  <p>So thank you very much @MA</p>
  <p>Sometimes people are too fast into closing questions!</p>