title: How to sort a ConcurrentSkipListMap by value?
body: <p>I'm trying to sort a ConcurrentSkipListMap by value in Java, here is my code :</p>
  
  <pre><code>ConcurrentSkipListMap&lt;String,Float&gt; cslMap = new ConcurrentSkipListMap(new Comparator() {
      public int compare(Object o1,Object o2) {
          return ((Comparable)((Map.Entry)(o1)).getValue()).compareTo(((Map.Entry)(o2)).getValue());
      }
  });
  cslMap_Map.put("B",0.2f);
  cslMap_Map.put("A",0.1f);
  cslMap_Map.put("C",1f);
  </code></pre>
  
  <p>Got an error message when compiling it:</p>
  
  <blockquote>
    <p>Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Map$Entry</p>
  </blockquote>
  
  <p>What's the correct way to do it ?</p>
  
  <p>Thanks for the answers, but in it's Java doc, it says "The map is sorted according to the natural ordering of its keys, <strong>or by a Comparator provided at map creation time</strong>", so how to supply it with a Comparator that sort by its values ?</p>