需要对数值的字符串数组进行排序 [英] Need to sort String array of numerical value

查看:80
本文介绍了需要对数值的字符串数组进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我必须在2个网格中以排序形式显示数据
适用于第一个网格-价格高昂的数据
对于第二个网格-值较低的数据

我正在字符串数组(string [5] [4])中获取数据
即data [0-5] {string [] {值",高价",低值",数量"}}


例如

Hi,
There are 2 grids in which i have to display data in sorted form
for 1st grid - data with high price
for 2nd grid - data with low value

i am getting the data in a string array (string[5][4])
i.e. data[0-5]{string []{"value","high price","low value","qty"}}


e.g.

string[][] newval = new string[][] { 
    new string[]{"12","113.12","121.90","12"},
    new string[]{"12","111.15","121.95","12"},
    new string[]{"12","115.16","121.92","12"},
    new string[]{"12","116.13","121.98","12"},
    new string[]{"12","114.11","121.95","12"}};



每次数据以&以上格式显示时5行时,我必须将这些网格填充为(网格1的前2个值和网格2的下2个值)

网格1

高价位-价值

网格2

低价值-数量

我必须从即将到来的数据中创建一个10的字符串数组,作为 string [10] [4] ,这样才能在每个网格条件网格1中显示10行以高价排序(数据类型为double)和grid2将按低值排序(数据类型为double).



each time data is coming in the format above & with 5 rows i have to fill these grids as(first 2 values for grid 1 & next 2 values for grid 2)

grid 1

high price-- value

grid 2

low value -- qty

i have to create a string array of 10 from the coming data as string[10][4] thus to display 10 rows in each grid condition grid 1 to be sorted on high price(data type double) and grid2 to be sorted on low value (data type double).

推荐答案



这是您要问的吗?

Hi,

Is this what you''re asking?

var list1 = newval.Select(x => new String[] { x[1], x[0] });
var list2 = newval.Select(x => new String[] { x[2], x[3] });



希望对您有所帮助.

我错过了排序:列表< t> ;.排序 [ ^ ]



Hope it helps.

I''m missing the sort: List<t>.Sort[^]



试试这个:
Hi,
Try this:
int[,] array = new int[3, 3] { { 1, 4, 2 }, { 4, 5, 1 }, { 7, 3, 8 } };
int[,] sortedByFirstElement = array.OrderBy(x => x[0]);
int[,] sortedBySecondElement = array.OrderBy(x => x[1]);
int[,] sortedByThirdElement = array.OrderBy(x => x[2]);


请参考 [


Refer this[^] also.



--Amit


这篇关于需要对数值的字符串数组进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆