I have an array of packets so that each packet has source IP and destination IP.
I want to find the best way to divide the array so that in the end I'll get a dictionary whose keys are IP and their value is all the packets sent from or to that IP.

For example, if this is my array:

```
let packets = [ {sourceIp:127.0.0.1, destIp:127.0.0.2}, 
                {sourceIp:127.0.0.2, destIp:127.0.0.3},
                {sourceIp:127.0.0.3, destIp:127.0.0.1},
                {sourceIp:127.0.0.2, destIp:127.0.0.1}]

```

I'm looking for a way to get-

```
result = { 127.0.0.1: [{sourceIp:127.0.0.1, destIp:127.0.0.2},{sourceIp:127.0.0.3, destIp:127.0.0.1},
                       {sourceIp:127.0.0.2, destIp:127.0.0.1}],
           127.0.0.2: [{sourceIp:127.0.0.1, destIp:127.0.0.2},{sourceIp:127.0.0.2, destIp:127.0.0.3},
                       {sourceIp:127.0.0.2, destIp:127.0.0.1}],
           127.0.0.3: [{sourceIp:127.0.0.2, destIp:127.0.0.3},{sourceIp:127.0.0.3, destIp:127.0.0.1}]
         }

```

Thank you:-)