按升序排序数组列表(数组列表中有计划记录) [英] Sort Array list with ascending order date(Array list have scheme records)

查看:79
本文介绍了按升序排序数组列表(数组列表中有计划记录)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有

一个列表<> =表方案

像这样显示

i have

one list<>=table scheme

it show like this

list[0]={''raja,'muthaiah,'male','11/2/12','chennai','tamil nadu','india'}                        11/2/12
list[1]={''vijay,'kumar,'male','2/7/12','chennai','tamil nadu','india'}                              2/7/12
list[2]={''kumar,'vel,'male','17/3/12','chennai','tamil nadu','india'}                              17/3/12
list[3]={''pradeep,'kumar,'male','14/6/12','chennai','tamil nadu','india'}                      14/6/12
list[4]={''gowtham,'manen,'male','18/2/12','chennai','tamil nadu','india'}                    18/2/12



上面的数据将被发布到一个地方...最后一个自动生成的ID为= 1000

所以,现在我想对FIFO方法生成id no以对日期基础类型进行排序



例外结果是....



above the data will be post one place ...that have last auto generate id is=1000

So, now i want to generate id no to FIFO method to sort on date basics type

I

excepted results is ....

1001=   11/2/12
1002=    18/2/12
1003=  17/3/12
1004= 14/6/12
1005= 2/7/12

推荐答案

我的解决方案更多是建议而不是解决方案...
谢尔盖是正确的,请使用System.Collections.Generic.List并创建自己的人"或客户"类.

所以在你班上有



DateJoined
区域
状态
国家

或物品是什么.

现在,如果您填充人员或客户类别"列表,则可以使用LINQ遍历它们,然后使用它们将其分类为日期升序"!

My solution is more of advice than a solution...
Sergey is correct, use System.Collections.Generic.List<> and create yourself a class of Person or client as it looks like.

So in your class have

First Name
Surname
DateJoined
Area
State
Country

or what ever the items are.

Now if you populate a List of Person or Client Class, you can iterate through them with LINQ, and use that to sort it into Date Ascending order!

List<clients> myClientList = new List<clients>(){};</clients></clients>



将使用结果填充myClientList,然后可以使用LINQ对它们进行排序.

了解LINQ(C#) [



myClientList would be populated with the results, and then you could sort them with LINQ.

Understanding LINQ (C#)[^]

Does that give you a bit of a helping hand to start with? Codeproject has a lot of really useful articles that will be able to assist you!


这如何,对我来说很麻烦


How about this, wroks for me


var list = new List<string[]>();

           list.Add(new[] {"raja", "muthaiah", "male", "11/2/12", "chennai", "tamil nadu", "india"});
           list.Add(new[] {"vijay", "kumar", "male", "2/7/12", "chennai", "tamil nadu", "india"});
           list.Add(new[] {"kumar", "vel", "male", "17/3/12", "chennai", "tamil nadu", "india"});
           list.Add(new[] {"pradeep", "kumar", "male", "14/6/12", "chennai", "tamil nadu", "india"});
           list.Add(new[] {"gowtham", "manen", "male", "18/2/12", "chennai", "tamil nadu", "india"});
         list=  new List<string[]>(list.OrderBy(n=>DateTime.Parse(n[3],CultureInfo.CreateSpecificCulture("en-GB"))));


这篇关于按升序排序数组列表(数组列表中有计划记录)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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