简体   繁体   中英

Is there a way to sort in ascending order a list of lists?

I have the following list of lists that I convert it in json.

"{"Calls":[{"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: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"]}],"StatusCode":1}"

My class is the following:

 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>();
        }
    }

Is there a way to sort in ascending order each call_info_id and the corellated dateOfBirth in each call_id ?

How about changing your setters and getters ie.

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;
    }
}

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM