How do I sort List<List<string>> according to number of fields?
The list got structure like
a|b|c|d|eeee|rere|ewew| ewqewq|ewew| ewew|ewewewewew|
By Sort I’d like to do it according to numbers of blockes (asc/desc)
EDIT
the <list<list<string>> is 'items' and I access each list by items[0] each of
these items[xx] is a list which means that I want them to sort the array to
a|b|c|d|eeee|rere|ewew| a|b|c|d|eeee|rere a|b|c|d|eeee
If you don’t need to sort ‘in place’ you can use LINQ to give you a new sorted, list.
Otherwise you’ll need to write your own Comparer that takes two lists and returns the ordering by their size.
Or, as @Josh points out, you can do this with a lambda expression.
IMO this latter works well if the comparison is relatively simple or used once, but the actual class may be preferable as the comparison gets more complex or if you need to repeat it in multiple places.