JSFiddle - React, Tailwind, and code Playground
JavaScript
var fruitForSale = {
1: {"type":"orange","UnitPrice":0.20},
2: {"type":"banana","UnitPrice":0.30},
3: {"type":"pear","UnitPrice":0.10},
4: {"type":"apple","UnitPrice":0.50},
5: {"type":"peach","UnitPrice":0.70}
},
sortedKeys = Object.keys(fruitForSale).sort(function (i,j) {
return fruitForSale[i]["type"] > fruitForSale[j]["type"];
});
console.log(sortedKeys);