Tuple. Cre..." />

Sort and matching the list using linq?

One way would be List listA = new List { "a", "b", "c" }; List listB = new List { 10, 5, 20 }; var joined = listA. Select((value, index) => Tuple. Create(value, listBindex)); List orderedListA = joined.

OrderByDescending(t => t. Item2) . Select(t => t.

Item1) .ToList() Edit: I've missed the Zip method. The line var joined = listA. Select((value, index) => Tuple.

Create(value, listBindex)) could be written as var joined = listA. Zip(listB, (s,i) => Tuple. Create(s,i)).

One way would be List listA = new List { "a", "b", "c" }; List listB = new List { 10, 5, 20 }; var joined = listA. Select((value, index) => Tuple. Create(value, listBindex)); List orderedListA = joined.

OrderByDescending(t => t. Item2) . Select(t => t.

Item1) .ToList(); Edit: I've missed the Zip method. The line var joined = listA. Select((value, index) => Tuple.

Create(value, listBindex)); could be written as var joined = listA. Zip(listB, (s,i) => Tuple. Create(s,i)).

How about using the Zip operator: List unsortedA = ... List unsortedB = ... var orderedTuples = unsortedA. Zip(unsortedB, Tuple. Create) .

OrderByDescending(tuple => tuple. Item2) .ToList(); // If required: var sortedA = orderedTuples. ConvertAll(tuple => tuple.

Item1); var sortedB = orderedTuples. ConvertAll(tuple => tuple. Item2); On another note, it appears like you should be using a tuple-type to store a character and an index together, rather than 'associating' them based on index.

With . Net 4.0 Zip and Anonymous types b. Zip(a, (x,y)=>new {Key=x, Value=y}).

OrderBy(x=>x. Key). Select(x=>x.

Value). ToList().

Var joined = listA. Select((value, index) => Tuple. List orderedListA = joined.

OrderByDescending(t => t. Select(t => t. Var joined = listA.

Select((value, index) => Tuple. Var joined = listA. Zip(listB, (s,i) => Tuple.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions