【发布时间】:2018-07-18 21:51:23
【问题描述】:
我有一些列表我想按一个值排序,然后将它们反转。 两个列表不是按它们自己的值排序,而是按第二个列表的值排序。
List<Sector> tempSectors = Lists.LSectors;
List<Sector> orderedByCTW = new List<Sector>();
List<Sector> orderedByCTM = new List<Sector>();
orderedByCTW = tempSectors;
orderedByCTM = tempSectors;
orderedByCTW.Sort((s1, s2) => s1.CLTW.Count.CompareTo(s2.CLTW.Count));
orderedByCTM.Sort((s1, s2) => s1.CLTM.Count.CompareTo(s2.CLTM.Count));
orderedByCTW.Reverse();
orderedByCTM.Reverse();
Utility.MostValueableSectorTW = orderedByCTW.FirstOrDefault();
Utility.MostValueableSectorTM = orderedByCTM.FirstOrDefault();
orderedByCTW也是按照CTM的值排序的,为什么呢?
【问题讨论】: