How Sort A List By A Part Of That String Desc

前端 未结 6 1701
一整个雨季
一整个雨季 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:29

    If the number always starts after the last underscore character, then this should work:

    var sortedList = list_lines
        .OrderByDescending(l => int.Parse(l.Substring(l.LastIndexOf("_") + 1)))
        .ToList();
    

提交回复
热议问题