title: How to concatenate strings in SQL Server, and sort/ order by a different column?
body: <p>I've seen many examples of concatenating strings in SQL Server, but if they worry about sorting, it's always by the column being concatenated.
  I need to order the values based on data in a different fields.</p>
  
  <p>Sample table:</p>
  
  <pre><code>ClassID | StudentName   | SortOrder
  -----------------------------
  A       |James          |1
  A       |Janice         |3
  A       |Leonard        |2
  B       |Luke           |2
  B       |Leia           |1
  B       |Artoo          |3
  
  </code></pre>
  
  <p>And the results I'd like to get are:</p>
  
  <pre><code>ClassID |StudentName
  --------------------------------
  A       |James, Leonard, Janice
  B       |Leia, Luke, Artoo
  </code></pre>
  
  <p>How can this be done in SQL Server 2016?
  (I'm looking forward to STRING_AGG in 2017, but we're not there yet...)</p>
  
  <p>Thanks!</p>