【问题标题】:Is there a way to sort in ascending order a list of lists?有没有办法按升序对列表列表进行排序?
【发布时间】:2020-10-25 16:17:53
【问题描述】:

我有以下列表,我将其转换为 json。

“{” 呼叫 “:[{” CALL_ID “:91402”,call_info_id “:[112,136,138,150,146,121,131,142,134,139,122,151,130,143,144,141,137,135,128,140,132,124,113,127,133,149,145],” call_info_timing_id “:10”,DATEOFBIRTH “:[” 2000-04-03T00:00:00" ,“2020 -09-28T10:40:30","2020-09-28T10:40:30","2020-09-28T10:40:30","2000-04-03T00:00:00","2000-04 -03T00:00:00","2020-09-28T10:40:30","2020-09-28T10:40:30","2020-09-28T10:40:30","2020-09-28T10 :40:30","2000-04-03T00:00:00","2020-09-28T10:40:30","2000-04-03T00:00:00","2020-09-28T10:40 :30","2020-09-28T10:40:30","2020-09-28T10:40:30","2000-04-03T00:00:00","2020-09-28T10:40:30 ","2020-09-28T10:40:30","2020-09-28T10:40:30","2020-09-28T10:40:30","2000-04-03T00:00:00", "2000-04-03T00:00:00","2020-09-28T10:40:30","2020-09-28T10:40:30","2020-09-28T10:40:30","2020 -09-28T10:40:30"]},{"call_id":91403,"call_info_id":[114,116,119,152,120,125,123,147,126,148,115,117],"call_info_timing_id":11,"dateOfBirth":["2000-04-03T00:00: "2020-09-28T10:40:30","2000-04-03T00:00:00","2020-09-28T10:40:30 ","2020-09-28T10:40:30","2020-09-28T10:40:30","2020-09-28T10:40:30","2020-09-28T10:40:30", "2020-09-28T10:40:30","2020-09-28T10:40:30","2000-04-03T00:00:00","2000-04-03T00:00:00"]}] "状态码":1}"

我的班级如下:

 public partial class get_active_call_info_id_Result
    {
        public int call_id { get; set; }
        public int call_info_id { get; set; }
        public int call_info_timing_id { get; set; }
        public System.DateTime dateOfBirth { get; set; }
      
    }

        public partial class get_active_call_info_ids
    {
        public int call_id { get; set; }
        public List<int> call_info_id { get; set; }
        public int call_info_timing_id { get; set; }
        public List<System.DateTime> dateOfBirth { get; set; }
        

        public get_active_call_info_ids()
        {
            call_info_id = new List<int>();
            dateOfBirth = new List<System.DateTime>();
        }
    }

有没有办法对每个call_info_id 和每个call_id 中的相关dateOfBirth 进行升序排序?

【问题讨论】:

    标签: c# json .net


    【解决方案1】:

    改变你的setter和getter怎么样?

    private List<int> _call_info_id;
    public List<int> call_info_id 
    { 
        get{
            return _call_info_id.OrderBy(a=>a).ToList();
        }
        set{
            _call_info_id = value;
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2013-10-16
      • 1970-01-01
      • 2021-11-17
      • 2020-03-28
      • 2011-12-06
      • 1970-01-01
      • 2020-10-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多