title: Google Sheets: Group Values in rows based on duplicate value in column
body: <p>I am trying to sort Google Sheets data in columns.</p>
  
  <p><strong>Raw Data</strong></p>
  
  <p><a href="https://i.stack.imgur.com/4Q1wX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4Q1wX.png" alt="enter image description here"></a></p>
  
  <p><strong>Desired Output</strong></p>
  
  <p><a href="https://i.stack.imgur.com/bl5zv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bl5zv.png" alt="enter image description here"></a></p>
  
  <p>I know that this can be offered with some time of <code>QUERY</code> function but I cannot get it to work exactly how I want. I have already read through <a href="https://webapps.stackexchange.com/questions/36103/how-to-group-data-in-a-google-spreadsheet">this thread</a> on Google Sheets and <a href="https://stackoverflow.com/questions/18060378/group-values-in-excel-according-duplicate-value-in-column">this thread</a> on Excel.</p>