title: How to collect a stream into a TreeMap
body: <p>I know this is a noob a question, but I couldn't find a simpe answer anywhere else. Question is: I need to write a method that returns a <code>SortedMap</code>, so a tree map should work just fine. 
  I have a <code>HashMap&lt; String, Skill&gt;</code>, the <code>Skill</code> class has both the methods <code>getName</code> and <code>getNumApplicants</code> and I need to return a <code>SortedMap&lt;String, Long&gt;</code>, with the name of the skill as a key and the number of applicants as value. This is where I stand:</p>
  
  <pre><code>private Map&lt;String,Skill&gt; skillMap = new HashMap&lt;&gt;();
  
  public SortedMap&lt;String, Long&gt; skill_nApplicants() {
  
      return skillMap.values().stream().collect(...);
  }
  </code></pre>
  
  <p>This is the Skill class</p>
  
  <pre><code>public class Skill {
  
      private String name;
      private List &lt;Position&gt; reqPosition = new ArrayList&lt;&gt;();
      private Long numApplicants;
  
      public void plusOneApplicant() {
          this.numApplicants++;
      }
  
      public Long getNumApplicants() {
          return numApplicants;
      }
      public Skill(String name) {
          super();
          this.name = name;
          this.numApplicants = 0L;
      }
      public String getName() {
          return name;
          }
  
      public List&lt;Position&gt; getPositions() {
          return reqPosition;
          }
      public void addReqPosition(Position p) {
          this.reqPosition.add(p);
          return;
      }
  }
  </code></pre>
  
  <p>I know this should be very easy, I just have a very hard time in understanding this all thing.</p>