title: Silverlight listbox orderby
body: <p>Is there a way to order this silverlight bound ListBox. I am not sure the way I have populated makes it easy?</p>
  
  <p>Code sample here:</p>
  
  <pre><code>  XElement _xml = XElement.Load("MSA.xml");
          {
              msa.Items.Clear();
  
              foreach (XElement value in _xml.Elements("channel").Elements("msa"))
              {
                  MSAFeedItem _item = new MSAFeedItem();
                  _item.Lat = double.Parse(value.Element("lat").Value);
                  _item.Long = double.Parse(value.Element("long").Value);
                  _item.Name = value.Element("n").Value;
  
  
   double dis1 = _item.Lat - curLatitude;
                          double dis2 = _item.Long - curLongitude;
  
                       var miles1 = Math.Pow(dis1, 2.0);
                       var miles2 = Math.Pow(dis2, 2.0);
  
                       var miles3 = miles1 + miles2;
  
                       var miles4 = Math.Sqrt(miles3) ;
  
                       var miles = miles4 * 62.1371192;
  
                      _item.Distance = Decimal.Truncate(Convert.ToDecimal(miles));
  
                   msa.Items.Add(_item);
  
              }
          }
  </code></pre>
  
  <p>It needs to be in ascending order according to a double or decimal value called 'miles'
  ListBox is called 'msa'</p>
  
  <p>Many thanks for any help or suggestions.</p>
  
  <p>EDIT: Ive added my distance code to help you understand whats going on, so _item.distance or 'miles' is the number it needs to ascend by.
  The code is a bit messy and doesnt work exactly rightt but you get the idea.</p>