i have an array of objects like this :
const array = [ { type: "sale", product: "aaa" } , { type: "rent", product: "bbb" } , { type: "sale", product: "ccc" }];
and i use this function to summarize the array
array.reduce((acc, o) => ((acc[o.type] = (acc[o.type] || 0) + 1), acc),{})
result :
{sale: 2, rent: 1}
but i wanna sort this summary object Ascending like this {rent: 1,sale: 2} Do I need to use another function ? Or modify the current function and how ?