首页 > 代码库 > C# List根据某一字段排序 将字段相同的排序到一起

C# List根据某一字段排序 将字段相同的排序到一起

            List<JZJLXQ_Prescription_Item> ciList = new List<JZJLXQ_Prescription_Item>();            List<JZJLXQ_Prescription_Item> tempItemList = new List<JZJLXQ_Prescription_Item>();            if (cfxxModel != null && cfxxModel.content != null && cfxxModel.content.prescriptionItems != null)            {                foreach (JZJLXQ_Prescription_Item reply in cfxxModel.content.prescriptionItems.list.item)                {                    ciList.Add(reply);                    tempItemList.Add(reply);                }            }            List<JZJLXQ_Prescription_Item> cfItemList = new List<JZJLXQ_Prescription_Item>();            foreach (JZJLXQ_Prescription_Item cfItem in ciList)            {                for (int i = 0; i < tempItemList.Count; i++)                {                    JZJLXQ_Prescription_Item itemTemp = (JZJLXQ_Prescription_Item)tempItemList[i];                    if (cfItem.YPZH.Equals(itemTemp.YPZH))                    {                        cfItemList.Add(itemTemp);                        tempItemList.RemoveAt(i);                        i--;                    }                }            }           cfItemList 为最终排序结果 

 

C# List根据某一字段排序 将字段相同的排序到一起