title: Grouping the Json object with multiple objects
body: <p>I need to group by sector and company-name of below json object.</p>
  
  <p>original JSON object:</p>
  
  <pre class="lang-js prettyprint-override"><code>data =[
     {"sector":"IT",
  "company-name": "ABC",
  "contact": "Person1",
  "position":"Accountant"
  },
  {"sector":"IT",
  "company-name": "ABC",
  "contact": "Person2",
  "position":"Accountant"
  },
  {"sector":"IT",
  "company-name": "ABC2",
  "contact": "Person1",
  "position":"Accountant"
  },
  {"sector":"IT",
  "company-name": "ABC2",
  "contact": "Person2",
  "position":"Accountant"
  },
  {"sector":"IT",
  "company-name": "ABC2",
  "contact": "Person3",
  "position":"Accountant"
  },
  {"sector":"Finance",
  "company-name": "Fin1",
  "contact": "Person3",
  "position":"Accountant"
  }
  ]
  </code></pre>
  
  <p>output:</p>
  
  <p>I could able to group by one i.e. company-name.Not how to extend this dynamically for multiple groups. </p>
  
  <pre class="lang-js prettyprint-override"><code>const result = {};
  const groubyfiled = 'company-name'
  this.data.foreach((item: any) =&gt; {
     const gname = item[groubyfiled];
     result[gname] = result[gname] || {};
     result[gnmae].items = result[gname].items || [];
     result[gname].items.push(item);
  });
  </code></pre>
  
  <p>output: </p>
  
  <pre class="lang-js prettyprint-override"><code>{
     "IT": {
        "ABC": {...},
        "ABC2": {...}
     },
    "Finance" : {
     "Fin1":{....}
  
     }
  }
  </code></pre>