title: rearrange a list of objects by type field in C#
body: <p>I have an incoming list of alerts and I use a MapFunction as:</p>
  
  <pre><code>private static BPAlerts MapToAlerts(List&lt;IntakeAlert&gt; intakeAlerts)
          {
              // Make sure that there are alerts
              if (intakeAlerts.IsNullOrEmpty()) return new BPAlerts { AllAlerts = new List&lt;BPAlert&gt;(), OverviewAlerts = new List&lt;BPAlert&gt;() };
  
              // All Alerts
              var alerts = new BPAlerts
              {
                  AllAlerts = intakeAlerts.Select(
                      alert =&gt; new BPAlert
                      {
                          AlertTypeId = alert.AlertTypeId ?? 8100,
                          IsOverview = alert.IsOverviewAlert.GetValueOrDefault(),
                          Text = alert.AlertText,
                          Title = alert.AlertTitle,
                          Type = alert.AlertTypeId == 8106 ? "warning" : "report",
                          Severity = alert.AlertSeverity.GetValueOrDefault(),
                          Position = alert.Position.GetValueOrDefault()
                      }).OrderBy(a =&gt; a.Position).ToList()
              };
  
  
              // Alerts displayed on the overview page
              alerts.OverviewAlerts =
                  alerts.AllAlerts
                      .ToList()
                      .Where(a =&gt; a.IsOverview &amp;&amp; !string.IsNullOrEmpty(a.Title))
                      .Take(3)
                      .ToList();
  
              return alerts;
          }
  </code></pre>
  
  <p>the BPAlerts type contains list of two type:</p>
  
  <pre><code> public class BPAlerts
      {
          public List&lt;BPAlert&gt; AllAlerts { get; set; }
          public List&lt;BPAlert&gt; OverviewAlerts { get; set; }
      }
  </code></pre>
  
  <p>And the BPAlert type is defined as:</p>
  
  <pre><code> public class BPAlert
      {
          public short AlertTypeId { get; set; }
          public string Type { get; set; }
          public int Severity { get; set; }
          public bool IsOverview { get; set; }
          public string Title { get; set; }
          public string Text { get; set; }
          public int Position { get; set; }
          public string Id { get; internal set; } = Guid.NewGuid().ToString();
      }
  </code></pre>
  
  <p>I want to achieve a task in which the MaptoAlerts function returns a alerts object with overviewalerts which are sorted based on the type of BPAlert. To be more clear in the following order if present:</p>
  
  <p>Confirmed Out of Business - 8106 \n
  Bankruptcy - 8105 \n
  Lack of Licensing - 8111 \n
  Investigations - 8109 \n
  Government Actions - 8103 \n
  Pattern of Complaints - 8104 \n
  Customer Reviews - 8112 \n
  Accreditation - 8110 \n
  Misuse of BBB Name - 8101 \n
  Advisory - 8107 \n
  Advertising Review – 8102 \n</p>