title: Function to sort a JSON object by value
body: <p>Example of the JSON I'm trying to sort:</p>
  <pre class="lang-json prettyprint-override"><code>{
    &quot;auctions&quot;: [{
          &quot;uuid&quot;: &quot;533cbc92429c4456b2c013607eed5c38&quot;,
          &quot;auctioneer&quot;: &quot;5ba9f43481854fe891f94dfbd771b065&quot;,
          &quot;profile_id&quot;: &quot;4bec273ae4fa4ebd80169b734d0702bc&quot;,
          &quot;coop&quot;: [&quot;5ba9f43481854fe891f94dfbd771b065&quot;],
          &quot;start&quot;: 1600978137016,
          &quot;end&quot;: 1600999737016,
          &quot;item_name&quot;: &quot;Hologram&quot;,
          &quot;item_lore&quot;: &quot;§8Furniture\n§8Colored\n\n§7Add some flare to your island\n§7with custom floating text!\n\n§6§lLEGENDARY&quot;,
          &quot;extra&quot;: &quot;Hologram Skull Item&quot;,
          &quot;category&quot;: &quot;misc&quot;,
          &quot;tier&quot;: &quot;LEGENDARY&quot;,
          &quot;starting_bid&quot;: 300000,
          &quot;item_bytes&quot;: &quot;H4sIAAAAAAAAAE1Ry26bQBS9dtIG01b5gkpUyhYFbAOmUheWTQKWAcfPmE01mIGMMwMWDE3wP/Q7vO03+MOqTtpNV1f3nHPPfckAHWgRGQBabWiTpPWzBe9GRZ3zlgwXHGUX0HFJgu8oyiqh+i2DvHiuKQ1fclxK0PYSuNGsLsYxMlUr1W21Z5qGag+6qYoslMZmjLAV66JuVhYHXHKCqw5IHL/yusTV39YSvFsjWmP4hZuJFj0+acnjhO4azxT5cqHR0NsfLC9fN/HIMz0meHdoThv7P63B0cag297kKcof6pittWlvTrE713ds9SMcJzRazmkwzoxg4xjbY0T9/cPR/xe7wX69D5bbYzj2ej5zjhFb0+3GN4Llqh+OJyzaPzfbzero7x1dxF5EJnb6qH0T08twlZDqQFHTgctpUWJJgFfw8Xwa3NVlTt7WBFlko4IKNhGscj5ZwyRRqoJhJaWoxAovlKaoS4VUFOUJfBaKF8KflF1d8YIJUYE4yTPl7W5fhMX1+WSeT3Tq3DvBeDjfSnAZIIbhg8Bd0SgrEROjXTuvvERDzksS1xxXEnSKkmQkX6IMPi3ccPZ9tpqP3OHCkd7+D5IbTsP7+dAXhnUtgBsztZHdTRM11nWk9gcWVm1s9NXdzhzocZrEtqEJW04YrjhiB7i2b7v9266m9L9qA2XmA7Th/RgxlGG4APgDfkDxxHQCAAA=&quot;,
          &quot;claimed&quot;: false,
          &quot;claimed_bidders&quot;: [],
          &quot;highest_bid_amount&quot;: 0,
          &quot;bin&quot;: true,
          &quot;bids&quot;: []
      }, {
          &quot;uuid&quot;: &quot;4803a8c0e1674dfb9bf7581975d6181f&quot;,
          &quot;auctioneer&quot;: &quot;aa277b630ed94690905b955024e4ae21&quot;,
          &quot;profile_id&quot;: &quot;16df394a108042a18c32a57684369aac&quot;,
          &quot;coop&quot;: [&quot;b00fc41206a74e5886767298081ff151&quot;, &quot;aa277b630ed94690905b955024e4ae21&quot;, &quot;ab8012ba98fa46d994e393406a0cccd5&quot;, &quot;9680e1dd20aa4e01b0bb79e6413983fe&quot;],
          &quot;start&quot;: 1600977772109,
          &quot;end&quot;: 1600999372109,
          &quot;item_name&quot;: &quot;Hologram&quot;,
          &quot;item_lore&quot;: &quot;§8Furniture\n§8Colored\n\n§7Add some flare to your island\n§7with custom floating text!\n\n§6§lLEGENDÄR&quot;,
          &quot;extra&quot;: &quot;Hologram Skull Item&quot;,
          &quot;category&quot;: &quot;misc&quot;,
          &quot;tier&quot;: &quot;LEGENDARY&quot;,
          &quot;starting_bid&quot;: 399999,
          &quot;item_bytes&quot;: &quot;H4sIAAAAAAAAAE1Ry26bQBS9dpIG01b5gkpUyhYFPwATqQvLJgHLgOO32VSDGZNxZsCCoQled9vv8Lbf4P5X1XG76erqnnPuuS8ZoAE1IgNArQ51Etd+1OCqn5Upr8lwwVFyAQ2HxPiBoqQQqt8yyNOXktLgNcW5BHU3hlvNbGEcIUM1t01LbRuGrlrd1lZFJtpGRoSwGTVF3TjP9jjnBBcNkDh+42WOi7+tJbhaIFpi+ImroRaunrV4NaSbyjVEPptqNHB3e9NNF1XUdw2XCd7pGaPK+k+rc7TU6bo9fA7TpzJiC23UnlDsTJobNv8WDGIazibUHyS6v7T19SGk3u7p4P2LLX+32Pmz9SEYuG2P2YeQLeh66en+bN4JBkMW7l6q9XJ+8HZ2U8R2SIbWdqV9EdPLcB2TYk9R1YDLUZZjSYDX8OF07D6UeUrOa4Issn5GBRsLVjkdzV4cK0XGsLKlKMcKz5QqK3OFFBSlMXwSilfCn5VNWfCMCVGGOEkT5Xy3z8Li5nQ0Tkc6sh9tf/Dr+0SCSx8xDO8F7ohGSY6YGO3GfuM56nGek6jkuJCgkeUkIekMJfBx6gTjr+P5pO/0prZ0/j9ITjAKHic9TxiWpQBuo2gTd40mUg1L19WO0cVq1zQ0FVmmrnXwdmO1TGHLCcMFR2wPN9Zdq3PX0pTOvdZUxh5AHd4NEEMJhguAPwiTikl0AgAA&quot;,
          &quot;claimed&quot;: false,
          &quot;claimed_bidders&quot;: [],
          &quot;highest_bid_amount&quot;: 0,
          &quot;bin&quot;: true,
          &quot;bids&quot;: []
      }
  }
  </code></pre>
  <p>I would like to sort the objects from lowest to highest using the <code>&quot;starting_bid&quot;</code> key's value. Is this possible? From my research I heard I had to convert the data to an array to search from it, is there a way to do that (since the JSON object came from an API request). Also, is it possible to make the 'sorting algorithm' into a function? I'm happy to give any info you need.</p>
  <p>Edit:
  Attempted Solutions (so far):
  Solution 1 (Didn't Work)</p>
  <pre class="lang-js prettyprint-override"><code>function sortByValue(data) {
       const sortable = Object.entries(data)
         .sort(([, a], [, b]) =&gt; a - b)
         .reduce((r, [k, v]) =&gt; ({ ...r, [k]: v }), {});
  }
  </code></pre>
  <p>Solution 2 (Thanks Besufkad Menji) (Worked):</p>
  <pre class="lang-js prettyprint-override"><code>function sortByValue(data) {
       data.auctions.sort((a, b)=&gt;a.starting_bid - b.starting_bid);
       return data;
  }
  </code></pre>