mardi 20 janvier 2015

Sorting List based on another float List in C#


Vote count:

0




Given two lists below in C#:



List<string> X = new List<string>({ "a", "b", "c", "d", "e", "f", "g", "h", "i"});
List<float> Y = new List<float> ({ 0.991f, 1.471f, 3.819f, 0.003f, 2.291f, 2.887f, 2.887f, 0, 1.0f});


What will be the cleanest/shortest way of sorting X using float values from Y to get the following output?



"h", "d", "a", "i", "b", "e", "f", "g", "c"


The order for the elements having the same float "key" does not matter.



asked 2 mins ago

purga

137






Sorting List based on another float List in C#

Aucun commentaire:

Enregistrer un commentaire