我有一个列表,我想以多种方式排序.
我的清单是用这个:
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));
Run Code Online (Sandbox Code Playgroud)
我开始使用每一行foreach(var line in theMainList).
现在,对于每一个line我需要比较某些位置并相应地对它们进行排序.
所以,第一我想比较是每个line.Speed和数字组织名单(所以如果速度是1,2,3,4,5等在列表中的第一行是具有行line.Speed等于1,然后2,等)
SECOND我想按现在的顺序排序更新的列表line.Speed.我想line.PackageStyle按顺序排序:
"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"
Run Code Online (Sandbox Code Playgroud)
第三,我想用Speed排序的第一个排序新的更新列表,然后你PackageStyle排序第二个...由line.PartNumber.再次,这将在数字上就像line.Speed是.
有没有办法做这个多重排序技术?
theMainList.OrderBy(l => l.Speed)
.ThenBy(l => l.PackageStyle)
.ThenBy(l => l.PartNumber);
Run Code Online (Sandbox Code Playgroud)