Sort map on value?
<p>if i have a map like this: </p>

<pre><code>Map&lt;Fruit, Double&gt; multiMap = new HashMap&lt;Fruit, Double&gt;();
</code></pre>

<p>is there a way for me to sort on the Double values while still keeping the Double values linked to the corresponding Fruit object?</p>

<p>initially i was thinking of doing something like this:</p>

<pre><code>public ArrayList&lt;Double&gt; sortAllValues() {
    ArrayList&lt;Double&gt; allEntries = new ArrayList&lt;Double&gt;();

    for (Entry&lt;Fruit, Double&gt; entry : multiMap.entrySet())
        allEntries.add(entry.getValue());
    }
return Collections.sort(allEntries);
}
</code></pre>

<p>but if i do this i lose the linkage between the Fruit and the Double value... any ideas?</p>

<p>Thanks in advance</p>
