title: Sort the Object's value inside the Hashmap<String, Object>
body: <p>I want to sort an Hashmap by the object's value. In this case, by country code.</p>
  
  <pre><code>  KEY              OBJECT                        
    String        LoyaltyCountry
                       - country name
                       - country code
                       - country loc
  </code></pre>
  
  <p>My code is as follows:</p>
  
  <pre><code>public static HashMap&lt;String, LoyaltyCountry&gt; loyaltyCountrySortMap(HashMap&lt;String, LoyaltyCountry&gt; loyaltyCountryMap) {
  
              if (loyaltyCountryMap != null) {
                  List keys = new ArrayList();
                  keys.addAll(loyaltyCountryMap.keySet());
                  Collections.sort(keys, new Comparator&lt;LoyaltyCountry&gt;() {
                      public int compare(LoyaltyCountry o1, LoyaltyCountry o2) {
                          return o1.getCountryName().compareTo(o2.getCountryName());
                      }
                  });
              }
  
              return loyaltyCountryMap;
          }
  </code></pre>
  
  <p>How can I do this correctly?</p>