Get a sorted list from a Map via Stream API
<p>I am trying to achieve the following scenario with the <code>Stream API</code> but with no success.</p>

<p>I have the following graph. The key is the name of the person and the set has the name of friends of the person (key).</p>

<pre><code>Map&lt;String, Set&lt;String&gt;&gt; fooGraph
</code></pre>

<p>I want to have a sorted ArrayList based on the number of friends (popularity), a person has.</p>

<p>For example,</p>

<p>this is the <code>fooGraph</code> with its values</p>

<pre><code>x -&gt; a,b,c

y -&gt; a

z -&gt; a,b,c,d,e,f

t -&gt; a,b,c,d
</code></pre>

<p>and at the end of the day, I want to have a list based on the popularity of a person. The list should look like the following</p>

<pre><code>z, t, x, y
</code></pre>

<p>How can it be achieved with <code>Stream API</code>?</p>