How to sort List> according to List number of fields?

前端 未结 5 615
渐次进展
渐次进展 2021-01-22 15:22

How do I sort List> according to number of fields?

The list got structure like

a|b|c|d|eeee|rere|ewew|
ewqewq|ewew|
ewew|ewewewewew|
<         


        
5条回答
  •  离开以前
    2021-01-22 16:27

    List> strings = new List>();
    
    // add your strings
    
    strings = new List>(from str in strings orderby str.Count select str);
    

    Obviously you can adapt this to fit your scenario, but this should give you the general idea of how to create a list that's sorted by the number of elements within a particular string in another list.

提交回复
热议问题