How Sort A List By A Part Of That String Desc

前端 未结 6 1642
一整个雨季
一整个雨季 2021-01-23 00:09

i have a list like this :

List list_lines = new List();
list_lines.add(\"name1__pass1__com__14__55\");
list_lines.add(\"name2__pas         


        
6条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-23 00:43

    Asc:

    list_lines = list_lines.OrderBy(s => int.Parse(s.Split(Separator, StringSplitOptions.None)[4])).ToList();
    

    Desc:

    list_lines = list_lines.OrderByDescending(s => int.Parse(s.Split(Separator, StringSplitOptions.None)[4])).ToList();
    

提交回复
热议问题