title: Collect by function with parameter in Java Stream API
body: <p>From the tutorial <a href="https://docs.oracle.com/javase/tutorial/collections/streams/reduction.html" rel="nofollow">here</a>, I see I can group objects by attribute:</p>
  
  <pre><code>Map&lt;Person.Sex, List&lt;Person&gt;&gt; byGender =
      roster
          .stream()
          .collect(
              Collectors.groupingBy(Person::getGender));
  </code></pre>
  
  <p>What if I need to group by a method that takes a parameter, for example <code>steve.get("height")</code> instead of <code>steve.getHeight()</code>?  I suspect this can be done with a lambda, but I can't find the correct syntax.  What I've got right now:</p>
  
  <pre><code>people.stream().collect(Collectcors.groupingBy(p -&gt; p.get("height")));
  </code></pre>
  
  <p>What is the correct syntax to use to group by the result of a lambda function?</p>