title: How to Sort JsonNode by an object value in java
body: <p>How can I get sorted value on basis of cost variable in ascending or descending order for product node? Or how can I modify the value of the product node by sorting it in the below JsonNode response?</p>
  <p><strong>JsonNode response:</strong></p>
  <pre><code>{
      &quot;products&quot;: [
          {
              &quot;Name&quot;: &quot;Marble&quot;,
              &quot;cost&quot;: 47.49
          },
          {
              &quot;Name&quot;: &quot;Mixer&quot;,
              &quot;cost&quot;: 59.99
          },
          {
              &quot;Name&quot;: &quot;Soap&quot;,
              &quot;cost&quot;: 3.99
          }
      ],
      &quot;details&quot;: [
          {
              &quot;area&quot;: 1090.098
          }
      ]
  }
  </code></pre>
  <p><strong>Excepted Response for descending:</strong></p>
  <pre><code>{
      &quot;products&quot;: [
          {
              &quot;Name&quot;: &quot;Mixer&quot;,
              &quot;cost&quot;: 59.99
          },
          {
              &quot;Name&quot;: &quot;Marble&quot;,
              &quot;cost&quot;: 47.49
          },
          {
              &quot;Name&quot;: &quot;Soap&quot;,
              &quot;cost&quot;: 3.99
          }
      ],
      &quot;details&quot;: [
          {
              &quot;area&quot;: 1090.098
          }
      ]
  }
  </code></pre>
  <p>Please guide me with proper solution, I am tired using comparator&lt;&gt; but this product node in <code>JsonNode</code> response does not have any POJO class so I can't use <code>obj.StringName</code> to compare.</p>