How can I order this array of objects by object value? I’m using TypeScript.
console.log(this.items);
Output:
(6) [{…}, {…}, {…}, {…}, {…}, {…}]
{id: 3, ref: "P-201721", active: 1, visible: 1, weigth: 0.3, …}
{id: 4, ref: "P-201722", active: 1, visible: 1, weigth: 0.3, …}
{id: 1, ref: "P-201710", active: 1, visible: 1, weigth: 0.5, …}
{id: 2, ref: "P-201711", active: 1, visible: 1, weigth: 0.5, …}
{id: 5, ref: "P-201831", active: 1, visible: 1, weigth: 0.2, …}
{id: 6, ref: "P-201832", active: 1, visible: 1, weigth: 0.2, …}
I tried this, but the array maintains the same order: Sort an array with arrays in it by string