title: Sort the map value based on precedence in java 8
body: <pre><code>{
      &quot;response&quot;: [
          {
              &quot;messages&quot;: [
                  {
                      &quot;parameters&quot;: {
                          &quot;PRECEDENCE&quot;: &quot;3&quot;,
                          &quot;ENTITY_CLASS&quot;: &quot;ACCOUNT&quot;
                      }
                  },
                  {
                      &quot;parameters&quot;: {
                          &quot;PRECEDENCE&quot;: &quot;16&quot;,
                          &quot;ENTITY_CLASS&quot;: &quot;PRODUCT&quot;
                      }
                  },
                  {
                      &quot;parameters&quot;: {
                          &quot;PRECEDENCE&quot;: &quot;1&quot;,
                          &quot;ENTITY_CLASS&quot;: &quot;ACCOUNT&quot;
                      }
                  }
              ]
          }
      ]
  }
  </code></pre>
  <p>I want the output should be ordered based value in ascending order</p>
  <pre><code>{
      &quot;response&quot;: [
          {
              &quot;messages&quot;: [
                  {
                      &quot;parameters&quot;: {
                          &quot;PRECEDENCE&quot;: &quot;1&quot;,
                          &quot;ENTITY_CLASS&quot;: &quot;ACCOUNT&quot;
                      }
                  },
                  {
                      &quot;parameters&quot;: {
                          &quot;PRECEDENCE&quot;: &quot;3&quot;,
                          &quot;ENTITY_CLASS&quot;: &quot;PRODUCT&quot;
                      }
                  },
                  {
                      &quot;parameters&quot;: {
                          &quot;PRECEDENCE&quot;: &quot;16&quot;,
                          &quot;ENTITY_CLASS&quot;: &quot;ACCOUNT&quot;
                      }
                  }
              ]
          }
      ]
  }
  </code></pre>
  <p>Current structure I have</p>
  <pre><code>Response 
          Set&lt;essage&gt; message
                          Map&lt;String, String&gt; parameters = new HashMap&lt;&gt;();
                          
  </code></pre>
  <p>I was trying by manual compare. is there a way I can iterate and sort the map values.</p>
  <p>How can I optimize efficiently?</p>