title: sort concurrent map entries by value
body: <p>Is there any way to create a thread-safe implementation of <code>Map</code> that maintains it's entries sorted by value? I know I can create a thread-safe <code>Map</code> like this</p>
  
  <pre><code>ConcurrentMap&lt;String, Double&gt; rankings = new ConcurrentHashMap&lt;String, Double&gt;();
  </code></pre>
  
  <p>And I can then get the entries sorted by value by passing it to a utility method like this:</p>
  
  <pre><code>public static &lt;K, V extends Comparable&lt;? super V&gt;&gt; Map&lt;K, V&gt; sortByValue(Map&lt;K, V&gt; map) {
      List&lt;Map.Entry&lt;K, V&gt;&gt; list = new LinkedList&lt;Map.Entry&lt;K, V&gt;&gt;(map.entrySet());
      Collections.sort(list, new Comparator&lt;Map.Entry&lt;K, V&gt;&gt;() {
          @Override
          public int compare(Map.Entry&lt;K, V&gt; o1, Map.Entry&lt;K, V&gt; o2) {
              return (o1.getValue()).compareTo(o2.getValue());
          }
      });
  
      Map&lt;K, V&gt; result = new LinkedHashMap&lt;K, V&gt;();
      for (Map.Entry&lt;K, V&gt; entry : list) {
          result.put(entry.getKey(), entry.getValue());
      }
      return result;
  }
  </code></pre>
  
  <p>But what I'm looking for is a thread-safe <code>Map</code> that <em>maintains</em> the entries sorted by value, so that I don't have to call a method such as the above after every insertion/removal in order to keep the entries sorted by value. I guess I'm looking for an implementation that combines the behavior of <code>ConcurrentHashMap</code> and <code>LinkedHashMap</code>, but haven't found one yet. </p>
  
  <p><a href="http://download.oracle.com/javase/6/docs/api/java/util/concurrent/ConcurrentSkipListMap.html" rel="noreferrer">ConcurrentSkipListMap</a> almost provides what I want, but it only seems to support sorting by key value.</p>