I have two columns
form.myDataTable.Rows[i][2 * cs] = corr;
form.myDataTable.Rows[i][2 * cs + 1] = "p" + Convert.ToString(col1) + " p" + Convert.ToString(col2);
I need to sort 2*cs
column by values and also corresponding names in column 2*cs+1
.
I am trying like this: var corrvalues = new Dictionary(); correlationvalues["p" + Convert.ToString(col1) + " p" + Convert.ToString(col2)] = corr; sortedvalues = correlationvalues.Values.OrderByDescending;
I am not clear how to use orderbydescending, i am new to c#. Thanks for help.
it is much easier, if you are using databinding.
you can fill the datagrid by
form.myDataTable.DataSource = Enumerable.Range(0, count).Select(i => new { Column1 = corr, Column2 = "p" + Convert.ToString(col1) + " p" + Convert.ToString(col2) }).ToArray();
doing a sort is then also easier
form.myDataTable.DataSource = Enumerable.Range(0, count).Select(i => new { Column1 = corr, Column2 = "p" + Convert.ToString(col1) + " p" + Convert.ToString(col2) }).OrderBy(k => k.Column2).ToArray();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.