I've been struggling to categorize elements with similar values in the array for quite some time, but I seem to be stuck
Array:
list = [
{id: "0", created_at: "foo1", value: "35"},
{id: "1", created_at: "foo1", value: "26"},
{id: "2", created_at: "foo", value: "13"},
{id: "3", created_at: "foo1", value: "11"},
{id: "4", created_at: "foo", value: "11"},
{id: "5", created_at: "foo1", value: "16"},
{id: "6", created_at: "foo", value: "26"},
{id: "7", created_at: "foo1", value: "13"},
{id: "8", created_at: "foo1", value: "16"}
];
The desired result should look like this:
var result = [
[
{id: "0", created_at: "foo1", value: "35"}
],
[
{id: "1", created_at: "foo1", value: "26"},
{id: "6", created_at: "foo", value: "26"}
],
[
{id: "2", created_at: "foo", value: "13"},
{id: "7", created_at: "foo1", value: "13"}
],
[
{id: "3", created_at: "foo1", value: "11"},
{id: "4", created_at: "foo", value: "11"}
],
[
{id: "5", created_at: "foo1", value: "16"},
{id: "8", created_at: "foo1", value: "16"}
]
];
Does anyone have any suggestions on how to achieve this? Thank you in advance.
Just a reminder: I am utilizing angular 5 framework.