title: c# how to sort sizes from list
body: <p>I would like to display my products with sizes from small to large?:</p>
  
  <p>M, XL, S would have to result in : S, M , XL</p>
  
  <p>c#</p>
  
  <pre><code> protected void Page_Load(object sender, EventArgs e)
          {
              List&lt;product&gt; list = new List&lt;product&gt;();
              product p1 = new product() {productid=1,Size="M" };
              product p2 = new product() { productid = 2, Size = "XL" };
              product p3 = new product() { productid = 3, Size = "S" };
              list.Add(p1);
              list.Add(p2);
              list.Add(p3);
              List&lt;product&gt; orderlist = list.OrderBy(o =&gt; o.Size).ToList();
  
              //list.Sort(size);
              foreach (var pr in orderlist)
              {
                  Response.Write(pr.Size +"&lt;br/&gt;");
              }
          }
  
  
  
     public class product
      {
          public int productid{ get; set; }
          public string Size { get; set; }
      }
  </code></pre>