title: Sort and group objects alphabetically by the first letter from an array in Angular?
body: <p>How can I sort and group objects alphabetically by the first letter from an array in angular? I have seen the example to do this Sort and group objects alphabetically  in <a href="https://www.cluemediator.com/sort-and-group-objects-alphabetically-by-the-first-letter-from-an-array-in-javascript" rel="nofollow noreferrer">Javascript</a> and  the exact answer and output json i am looking in Angular.</p>
  <p>As of now My api json is like <a href="https://stackblitz.com/edit/angular-fnvhnn-nijmv7?file=app%2Fexpansion-overview-example.html" rel="nofollow noreferrer">this stackblitz</a></p>
  <p>Expexted api json would like <a href="https://stackblitz.com/edit/angular-fnvhnn-swvrba?file=app%2Fexpansion-overview-example.ts" rel="nofollow noreferrer">this stackblitz</a></p>
  <p>I have tried this but i am unable to found the solution in angular.</p>
  <p>real Json:</p>
  <pre><code>employees = [
    { name: &quot;Abigail&quot;, age: &quot;25&quot; },
    { name: &quot;Axle&quot;, age: &quot;29&quot; },
    { name: &quot;Brianna&quot;, age: &quot;25&quot; },
    { name: &quot;Brooklyn&quot;, age: &quot;23&quot; },
    { name: &quot;Camila&quot;, age: &quot;24&quot; },
    { name: &quot;Charlotte&quot;, age: &quot;28&quot; },
    { name: &quot;David&quot;, age: &quot;22&quot; }
  ];
  </code></pre>
  <p>expecting json after sort and group objects alphabetically by the first letter from an array would like:</p>
  <pre><code>[
    {
      &quot;alphabet&quot;: &quot;A&quot;,
      &quot;record&quot;: [
        { &quot;name&quot;: &quot;Abigail&quot;, &quot;age&quot;: &quot;25&quot; },
        { &quot;name&quot;: &quot;Axle&quot;, &quot;age&quot;: &quot;29&quot; }
      ]
    },
    {
      &quot;alphabet&quot;: &quot;B&quot;,
      &quot;record&quot;: [
        { &quot;name&quot;: &quot;Brianna&quot;, &quot;age&quot;: &quot;25&quot; },
        { &quot;name&quot;: &quot;Brooklyn&quot;, &quot;age&quot;: &quot;23&quot; }
      ]
    },
    {
      &quot;alphabet&quot;: &quot;C&quot;,
      &quot;record&quot;: [
        { &quot;name&quot;: &quot;Camila&quot;, &quot;age&quot;: &quot;24&quot; },
        { &quot;name&quot;: &quot;Charlotte&quot;, &quot;age&quot;: &quot;28&quot; }
      ]
    },
    {
      &quot;alphabet&quot;: &quot;D&quot;, &quot;record&quot;: [
        { &quot;name&quot;: &quot;David&quot;, &quot;age&quot;: &quot;22&quot; }
      ]
    }
  ]
  </code></pre>
  <p>expected output like:</p>
  <pre><code>A
  Abigail
  Axle
  B
  Brianna
  Brooklyn
  C
  Camila
  Charlotte
  D
  David
  </code></pre>