I have a list of parameters:
List<double> parameters = new List<double>() { 3.56, 8.9, 1.7, 0.5, 4.69 };
And a list of generic objects:
List<object> objects= new List<object>() { objA, objB, objC, objD, objE };
How can I sort "objects" list accordingly with the sorting of "parameters" list?
You can use the Linq function OrderBy
to sort the objects using their respective index in the parameters list as a key.
List<double> parameters = new List<double>() { 3.56, 8.9, 1.7, 0.5, 4.69 };
List<object> objects = new List<object>() { objA, objB, objC, objD, objE };
objects = objects.OrderBy(x => parameters[objects.IndexOf(x)]).ToList();
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다