public struct ItemInfo
{
public string ID;
public string Name;
public double EntryTime;
public ItemInfo(string iD, string bagName, double entryTime) : this()
{
ID = iD;
BagName = bagName;
EntryTime = entryTime;
}
}
List<ItemInfo> itemList = new List<ItemInfo>();
itemList.Sort( (x,y) => (x.EntryTime>y.EntryTime)?1:-1);
// sort according to EntryTime from small to big
x.EntryTime > y.EntryTime means x and y need to be swapped, so the result is 1.
按照EntryTime的值从小到大排序
如果上述方法报错:可以调整为下面的方式
bagList.Sort( (x,y) => (x.EnterTime.CompareTo(y.EnterTime)));