Sorting a generic list

One of the nice features of  System.Collection.Generics.List is it is able to sort on the go with a IComparable, and you can do that simply with an anonomous method
This is simply done like so.

   1:  List<Attribute> attributes = Entity.Get();
   2:  attributes.Sort
   3:  (
   4:      delegate( Attribute firstAttribute, Attribute secondAttribute )
   5:      {
   6:          return firstAttribute.Index.CompareTo( secondAttribute.Index );
   7:      }
   8:  );

No Comments