title: error: Object cannot be converted to String
body: <p>Does anyone have any help with this error?</p>
  
  <pre><code>error: incompatible types: Object cannot be converted to String
  </code></pre>
  
  <p>I am passing a <code>HashMap</code> into a function with the intention of iterating through its keyset and storing them into a list for ordering, here is my code</p>
  
  <pre class="lang-java prettyprint-override"><code>public HashMap mapReorder(HashMap map) {
  
      /* Clear the list ready for input */
      mapList.clear();
  
      /* Iterate through the keys in the map */
  
      for(String keys : map.keySet()) {
          double mapKey = keys.getValue();
          mapList.add(mapKey);
      }
  
      /* Sorting the order by ascending value (Internal Frequency Rank) */
      Collections.sort(mapList);
  
      /* Populating HashMap with ordered list */
      for(double frequencies : mapList) {
          orderedMap.put(keys , frequencies);
      }
  
      return null;
  }
  </code></pre>