title: How to sort a hashmap consisting of Class objects as key and another hashmap as value in java?
body: <p>I'm fairly new to Java and found some resources on how to sort the hashmap based on certain attributes of the key object. However, I'm still not able to figure out what I'm missing in my code.</p>
  <p>I would really appreciate any help.</p>
  <p>I have a Monkey class, one of whose attribute is name. And, the location of the monkey could be either {&quot;isolationId&quot; : someInteger} or {&quot;enclosureId&quot;: someInteger}.</p>
  <p>And my hashmap looks like this:</p>
  <pre><code>HashMap&lt;Monkey, HashMap&lt;String, Integer&gt;&gt; monkeyAndLocation = new HashMap&lt;Monkey, HashMap&lt;String, Integer&gt;&gt;();
  </code></pre>
  <p>Now, I want to sort the <code>monkeyAndLocation</code> with respect to the name attribute of the monkey object.</p>
  <p>Can you help me with this?</p>