title: How to transform an array into matrix by grouping in typescript
body: <p>How can I transform the following array or objects into a new array or objects where each key element has the key element from the grouping and a inner collection witht the elements from the grouping.</p>
  
  <p>i.e I want to turn this array</p>
  
  <pre><code>[
   { "type": "1", "name": "a", "age": "10" },
   { "type": "1", "name": "b", "age": "11" },
   { "type": "2", "name": "c", "age": "12" }
  ]
  </code></pre>
  
  <p>into</p>
  
  <pre><code>[
   { "key": "1", "elements": [{"name": "a", "age": "10"},
                           {"name": "b", "age": "11"}]},
   { "key": "2", "elements": [{"name": "c", "age": "12"}]}
  ]
  </code></pre>
  
  <p>Is this possible and if so how?</p>
  
  <p>I also want to bind this new object twice to to an *ngFor so the inner element needs to be an array or can I do that in some other way?</p>