I have array like this one below. How can I group this array by lat and lng?
[{
name: "a",
address: {
lat: 5,
lng: 9,
street: "aaa"
}
}, {
name: "b",
address: {
lat: 2,
lng: 1,
street: "bbb"
}
}, {
name: "c",
address: {
lat: 5,
lng: 9,
street: "ccc"
}
}]
Output array should look like this. New object should contain lat, lng and array of gruped objects (without lat and lng in the adress)
[
{
lat: 5,
lng: 9,
items: [{
name: "a",
adress: {
street: "aaa"
}
}, {
name: "c",
adress: {
street: "ccc"
}
}]
}, {
lat: 2,
lng: 1,
items: [
{
name: "b",
adress: {
street: "bbb"
}
}
]
}
]