Order List<Object> by property name

This question already has an answer here:

  • How to Sort a List<T> by a property in the object 19 answers

  • you would need to calculate a key to sort by

    List<Test> ordered = values.OrderBy(v => 
             v.Value.StartsWith(">") ? "ZZ" + v.Value : v.Value
    ).ToList();
    

    "ZZ" is an arbitrary key that will sort the values starting with ">" after all English terms. (Being the last letter in the alphabet and no English words starting with two Zs). SInce ">" has a lower byte value than any letter one Z is not enough, since any valid english term would sort after anything staring with Z>

    链接地址: http://www.djcxy.com/p/70944.html

    上一篇: 我如何按姓氏排序?

    下一篇: 按属性名称排序列表<对象>