code: private <K, V> List<Map.Entry<K, V>> sortedEntryList(Map<K, V> obj) {
          List<Map.Entry<K, V>> entryList = new ArrayList<Map.Entry<K, V>>(obj.entrySet());
  
          Collections.sort(entryList, new Comparator<Map.Entry<K, V>>() {
              @Override
              @SuppressWarnings({ "unchecked", "rawtypes" })
              public int compare(Entry<K, V> o1, Entry<K, V> o2) {
                  K k1 = o1.getKey();
                  K k2 = o2.getKey();
  
                  if (k1 instanceof Comparable) {
                      return ((Comparable) k1).compareTo(k2);
                  }
  
                  return k1.hashCode() - k2.hashCode();
              }
          });
  
          return entryList;
      }
docs: diffs to match up better.