title: Sort Map by value in java
body: <p>My goal is to have is given a map of  to return an ascending array/list of sorted key values. For example:</p>
  
  <p>Input: the Map containing the following key/value entries separated by a space:</p>
  
  <pre><code>"Apple" 10
  "Orange" 8
  "Kiwi" 15
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>{Orange;Apple;Kiwi}
  </code></pre>
  
  <p>The only other approach I could think of was creating a <code>Map&lt;Integer,Set&lt;String&gt;&gt;</code> and then sorting by the key which is fairly convoluted. I got this approach to work but it seems rather inefficient in terms of code and logic. Thanks so much!</p>