我有一个列表,希望以多种方式进行排序。我的列表是使用以下方法制作的:theMainList.Add(new LoadLine(theChipList[count].Name, theChipList[count].PartNumber, theChipList[count].XPlacement, theChipList[count].YPlacement, theChipList[count].Rotation, theChipList[count].PkgStyle, theChipList[count].PackageType, theChipList[count].PartDescription, theChipList[count].Feeder, theChipList[count].Vision, theChipList[count].Speed, theChipList[count].Machine, theChipList[count].TapeWidth, theChipList[count].PlacingTime));我首先使用foreach(var line in theMainList)获取每一行。现在,对于每个line,我需要比较某些位置并进行相应排序。因此,首先我要比较的是每个line.Speed并按数字组织列表(因此,如果速度为1,2,3,4,5,依此类推,列表中的第一行将是具有等于1,然后等于2,依此类推)第二,我想再次按line.Speed的顺序对更新后的列表进行排序。我想按以下顺序对line.Speed进行排序:"FIDUCIAL", "FID", "FID0", "FID1", "FID2", "FID3", "FID4", "FID5","FID6", "FID7", "FID8", "FID9", "RES", "0402", "0201", "0603","0805","1206", "1306", "1608", "3216", "2551", "1913", "1313","2513","5125", "2525", "5619", "3813", "1508", "6431", "2512","1505","2208", "1005", "1010", "2010", "0505", "0705", "1020","1812","2225", "5764", "4532", "1210", "0816", "0363", "SOT"第三,我想对新的更新列表进行排序,首先将line.PackageStyle排序,然后将Speed进行第二次排序...由PackageStyle排序。同样,这在数值上就像line.PartNumber一样。有什么方法可以做这种多分类的技术吗? (adsbygoogle = window.adsbygoogle || []).push({}); 最佳答案 使用Linq的OrderBy()和ThenBy()方法:theMainList.OrderBy(l => l.Speed) .ThenBy(l => l.PackageStyle) .ThenBy(l => l.PartNumber); (adsbygoogle = window.adsbygoogle || []).push({});
09-28 03:42