title: How to get 5 highest values from a hashmap?
body: <p>I have a Hashmap that links a zipcodes stored as keys and population stored as values in a hashmap.</p>
  
  <p>The hashmap contains around 33k entries.</p>
  
  <p>I'm trying to get the 5 highest population values from 5 zip codes and print out the 5 zip codes ASSOCIATED with the 5 highest population, but I'm having trouble understanding the algorithm of how to do it.</p>
  
  <p>If it was just one, its easy but the 5 restriction is giving me some trouble.</p>
  
  <p>I know to store the 5 values in an int array and I have a counter to determine when 5 of them are stored, but thats it.</p>
  
  <p>Thanks</p>
  
  <pre><code>    int populatedCounter = 0;
  
      int[] populatedZip = new int[5];
  
      it = zipCodePop.entrySet().iterator();
      while (it.hasNext())
      {
          Map.Entry pairs = (Map.Entry)it.next();
  
          for (int i = 0; i &lt; populatedZip.length; i++)
          {
  
          }
      }
  
  }
  </code></pre>