title: How do I convert this Java code from using TreeMap to TreeMultiMap?
body: <p>I have a method thats returns a widget with the highest value for an attribute call source, this works fine except when there are multiple widgets with the same
      highest value for source, in this case it only returns the last widget added</p>
  
  <pre><code>private Widget getWidgetWithMostSources(List&lt;Widget&gt; Widgets)
  {
      SortedMap&lt;Integer,Widget&gt; mapOfWidgetsSortedBySources = new TreeMap&lt;Integer, Widget&gt;();
      for(Widget next:Widgets)
      {
          mapOfWidgetsSortedBySources.put(next.getSources().intValue(), next);
      }
      //Just return the Widget with the highest source value
      Widget Widget = mapOfWidgetsSortedBySources.get(mapOfWidgetsSortedBySources.lastKey());
      return Widget;
  }
  </code></pre>
  
  <p>So im trying to use Google Guavas TreemultiMap instead but I am having two problems, </p>
  
  <ol>
  <li><p>It doesnt like the generic variables declared when I contruct the TreeMultiMap. <strong>Update</strong> I think it is because Widget does not implement comparable but I cannot modify the Widget class this is provided by a third party. I only need sorted key and multivalues for keys, I dont need sorted values so perhaps there is another class I could use ?</p></li>
  <li><p>there is no lastKey() method, so how can I fix this:</p></li>
  </ol>
  
  <p>Code:</p>
  
  <pre><code>private List&lt;Widget&gt; getWidgetWithMostSources(List&lt;Widget&gt; Widgets) {
      List&lt;Widget&gt; filteredWidgets = new ArrayList&lt;Widget&gt;();
      TreeMultimap&lt;Integer, Widget&gt; mapOfWidgetsSortedBySources = TreeMultimap.create();
      for (Widget next : Widgets) {
          mapOfWidgetsSortedBySources.put(next.getSources().intValue(), next);
      }
      //Just return the Widget with the highest source linked to the acoustid
      Set&lt;Widget&gt; WidgetsWithHighestSources = mapOfWidgetsSortedBySources.get(mapOfWidgetsSortedBySources.keys().lastKey());
      filteredWidgets.addAll(WidgetsWithHighestSources);
      return filteredWidgets;
  }
  </code></pre>
  
  <p><strong>Update</strong></p>
  
  <p>This compiles and I think is okay for what I want:</p>
  
  <pre><code>TreeMultimap&lt;Integer, Recording&gt; mapOfRecordingsSortedBySources = TreeMultimap.create(Ordering.natural(), Ordering.arbitrary());
  </code></pre>