c# - Sort Key/Pair based on a calculation -


i have keyvaluepair in value contains generic list of 1 of class.

so each value calculate 1 column , based on value display in table format.

but here problem is: each list of values contains 1 row 0 column value calculation.

so want value on top place. right can @ place.

so how can sort based on calculation.?

here code:

 @foreach (keyvaluepair<string, list<myclass>> keyvaluepair in aclient.eselectiondictionary) {     foreach (myclass edata in keyvaluepair.value)     {         string weight;         ............         //here comes calculations         ............         if (weight == 0d)         {             addclass = "class=hidden";         }         else         {             addclass = "class=main";         }     } } 

so here values in edata, weight 0d except 1 value.

create new dictionary based on previous 1 list ordered custom function calculate column index:

var reshuffled = aclient.eselectiondictionary.todictionary(    kvp => kvp.key,    kvp => kvp.value.orderby(calculatecolumnindex) ); 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -