title: How to iterate through Map by values and if the values are same sort them by key?
body: <p>I have teams and their points in a HashMap.I am able to sort them by their values.  </p>
  
  <pre><code>Map&lt;String, Integer&gt; sortedMap = Points.entrySet().stream()
              .sorted(Collections.reverseOrder(Map.Entry.comparingByValue()))
              .collect(Collectors.toMap(Entry::getKey, Entry::getValue, (e1, e2) -&gt; e1, LinkedHashMap::new));
  </code></pre>
  
  <p>Now i would like to iterate over the sortedMap and print the keys in order and if there are matching values, then sort the keys having the same values and then print the result.</p>