I have a list of C# entities. My entity is defined as follows:
public class Item
{
// the id of an item
public Guid ID { get; set; }
// if this
Literally, to sort the list, you should use method called Sort
. You just need to provide correct comparator, it means you need to define a method which will compare two items as you defined (by level, then createdate). Look at MSDN here:
http://msdn.microsoft.com/en-us/library/w56d4y5z.aspx
For example you can use a lambda like this:
mylist.Sort((x,y) => {
int c = x.Level.CompareTo(y.Level);
if(c==0) c = x.CreateDate.CompareTo(y.CreateDate);
return c;
});
Note that I didn't compile and test this code in Visual Studio. Maybe it isn't 100% right but hopefully it showed you where to start.