title: how to group objects in array that are pointing at eact other
body: <p>I have an array of objects, each object is pointing at another object in the "related" field.</p>
  
  <p>I need to group the object with the related field so I can output them in groups on my website.</p>
  
  <p>how can I group something like this</p>
  
  <pre><code>[
    {
      id: 1,
      name: "dog",
      related: "cat",
    },
    {
      id: 2,
      name: "cat",
      related: "dog",
    },
    {
      id: 3,
      name: "shark",
      related: "whale",
    },
  ];
  </code></pre>
  
  <p>to this ?</p>
  
  <pre><code>
  [
    [
      {
        id: 1,
        name: "dog",
        related: "cat",
      },
      {
        id: 2,
        name: "cat",
        related: "dog",
      },
    ],
    [
      {
        id: 3,
        name: "shark",
        related: "whale",
      },
    ],
  ];
  </code></pre>