C# list sort by two columns

前端 未结 7 1125
慢半拍i
慢半拍i 2020-12-15 21:08

I have a C# custom object list that I need to sort by two different variables one is a boolean and the other is a string. I can sort by either of the criteria, but

7条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-15 21:47

    Comparison Chain in C#

    Here's my comparison chain solution. It will take care of aggregating all comparer classes you are interested in sorting by. the builder pattern makes it easy to provide columns to sort by and get a sorted list in return.

提交回复
热议问题